2011-12-16 21:58:42 +01:00
|
|
|
/*
|
|
|
|
Keyboard test
|
|
|
|
|
2012-11-04 22:49:14 +01:00
|
|
|
For the Arduino Leonardo, Micro or Due
|
2012-10-21 18:36:54 +02:00
|
|
|
|
2011-12-16 21:58:42 +01:00
|
|
|
Reads a byte from the serial port, sends a keystroke back.
|
|
|
|
The sent keystroke is one higher than what's received, e.g.
|
|
|
|
if you send a, you get b, send A you get B, and so forth.
|
|
|
|
|
|
|
|
The circuit:
|
|
|
|
* none
|
|
|
|
|
|
|
|
created 21 Oct 2011
|
2012-03-27 21:00:24 +02:00
|
|
|
modified 27 Mar 2012
|
2011-12-16 21:58:42 +01:00
|
|
|
by Tom Igoe
|
|
|
|
|
2012-11-04 22:49:14 +01:00
|
|
|
This example code is in the public domain.
|
2011-12-16 21:58:42 +01:00
|
|
|
|
|
|
|
http://www.arduino.cc/en/Tutorial/KeyboardSerial
|
|
|
|
*/
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
// open the serial port:
|
2012-11-04 22:49:14 +01:00
|
|
|
Serial.begin(9600);
|
2012-03-27 21:00:24 +02:00
|
|
|
// initialize control over the keyboard:
|
|
|
|
Keyboard.begin();
|
2011-12-16 21:58:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
// check for incoming serial data:
|
|
|
|
if (Serial.available() > 0) {
|
|
|
|
// read incoming serial data:
|
|
|
|
char inChar = Serial.read();
|
|
|
|
// Type the next ASCII value from what you received:
|
|
|
|
Keyboard.write(inChar+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|