A môže tam byť chyba, lebo som to písal v poznámkovom bloku.
Kód: Vybrat vše
#include <Keyboard.h>
int data = 0;
int step = 0;
void setup() {
Serial.begin(9600); //prenosova rychlost
Keyboard.begin();
}
void loop() {
if Serial.available(){
data = Serial.read();
switch (step){
case 0: //marker
if (data==0xA5){
step++;
else
step=0;
}
break;
case 1: //command
if (data==0x02){
step++;
else
step=0;
}
break;
case 2: //id high
step++;
break;
case 3: //id low
step++;
break;
case 4: //parameter
switch (data){
case 0x42:
Keyboard.print("A");
step++;
break;
case 0x4A:
Keyboard.print("B");
step++;
break;
case 0x52:
Keyboard.print("C");
step++;
break;
case 0x5A:
Keyboard.print("D");
step++;
break;
case 0x62:
Keyboard.print("E");
step++;
break;
case 0x60:
Keyboard.print("0");
step++;
break;
case 0x41:
Keyboard.print("1");
step++;
break;
case 0x40:
Keyboard.print("2");
step++;
break;
case 0x49:
Keyboard.print("3");
step++;
break;
case 0x48:
Keyboard.print("4");
step++;
break;
case 0x51:
Keyboard.print("5");
step++;
break;
case 0x50:
Keyboard.print("6");
step++;
break;
case 0x59:
Keyboard.print("7");
step++;
break;
case 0x58:
Keyboard.print("8");
step++;
break;
case 0x61:
Keyboard.print("9");
step++;
break;
default:
step=0;
break;
}
break;
case 5: //checksum
step=0;
break;
default:
step=0;
break;
}
}
}