17.- First tests with the arduino electronics

La veritat és que no se gaire com començar.

El tema és que hi ha massa coses juntes en aquest projecte, la electrònica té bastants components que no he fet servir mai i he d'apendre com funcionen i quin codi els fa funcionar. Després no sé massa programar en C (per Arduino) serà la segona vegada que programo una placa d'aquestes i hauré d'anar descobrint les ordres i fins hi tot com s'escriuen les coses més senzilles perquè encara no ho sé.

De moment començaré descobrir com funciona un keypad perquè podria ser un substitut d'un taulell petit:

La verdad es que no se muy bien cómo empezar.

El tema es que hay demasiadas cosas juntas en este proyecto, la electrónica tiene bastantes componentes que no he usado nunca y tengo que aprender cómo funcionan y qué código los hace funcionar. Después no sé demasiado programar en C (para Arduino) será la segunda vez que programo una placa de estas y tendré que ir descubriendo las órdenes e incluso cómo se escriben las cosas más sencillas porque todavía no lo sé.

De momento empezaré a descubrir cómo funciona un keypad porque podría ser un sustituto de un tablero pequeño:

The truth is, I don't know much about how to get started.

The issue is that there are too many things together in this project, electronics have quite a few components that I have never used and I have to learn how they work and what code makes them work. Then I do not know too much programming in C (for Arduino) will be the second time I program a board of these and I will have to discover the commands and even how to write the simplest things because I still do not know.

For the momenet I'll start figuring out how a keypad works because it could be a substitute for a small counter:




//This code sends the command "c2c4" trough serial port to the computer when pressing a key. it also sends
//"e2e3" pressing another key. When using a chess program that allows the keyboard entry, this keys
//are used as a chess movements.


#include <Keypad.h>

#include <Keyboard.h>
#include <SPI.h>
#include <Wire.h>

const byte rowsCount = 4;
const byte columsCount = 4;

char keys[rowsCount][columsCount] = {
{ '1','2','3', 'A' },
{ '4','5','6', 'B' },
{ '7','8','9', 'C' },
{ '#','0','*', 'D' }
};

const byte rowPins[rowsCount] = { 11, 10, 9, 8 };
const byte columnPins[columsCount] = { 7, 6, 5, 4 };

Keypad keypad = Keypad(makeKeymap(keys), rowPins, columnPins, rowsCount, columsCount);

void setup() {
Serial.begin(9600);
Keyboard.begin();

}

void loop() {
char key = keypad.getKey();

switch(key)
{
case '1':
Keyboard.print("c2c4");
delay(250);
break;

case '2':
Keyboard.print("e2e3");
delay(250);
break;
}
}

The code seams to be very simple, now I need to read the board and send the output and arrival squares instead of random commands.



Comentaris

Entrades populars d'aquest blog

45.- Weighting the pieces

3.- Sensors II

21.- Electronic scheme (updated 26/08/2020)