Stap 5: Codering... @ arduino Leonardo
SoftwareSerial mySerial (10, 11); RX, TX
VOID Setup {}
Serial.begin(9600);
terwijl (!. Seriële) {}
Keyboard.begin (); mySerial. begin(9600);
}
}
void loop {}
ingang voor seriële gebruiken om de muis te besturen:
Als (mySerial. beschikbaar ()) {}
int inChar = mySerial. lezen ();
schakelaar (inChar) {}
Case '1':
Keyboard.Press('m'); delay(100);
Keyboard.release('m');
breken;
Case '2':
Keyboard.Press(KEY_LEFT_ARROW); Keyboard.Press('s');delay(300); Keyboard.release(KEY_LEFT_ARROW); Keyboard.release('S');
breken;
Case '3':
Keyboard.Press(KEY_RIGHT_ARROW); Keyboard.Press('s');delay(300); Keyboard.release(KEY_RIGHT_ARROW); Keyboard.release('S');
breken;
Case '4':
Keyboard.Press('s'); delay(500); Keyboard.release('S');
breken;
Case '5':
Keyboard.Press(KEY_RIGHT_ARROW); delay(500); Keyboard.release(KEY_RIGHT_ARROW);
breken;
Case "6":
Keyboard.Press(KEY_LEFT_ARROW); delay(500); Keyboard.release(KEY_LEFT_ARROW);
breken;
}
}
}