| 1 |
/* |
| 2 |
Keyboard test |
| 3 |
|
| 4 |
For the Arduino Leonardo, Micro or Due |
| 5 |
|
| 6 |
Reads a byte from the serial port, sends a keystroke back. |
| 7 |
The sent keystroke is one higher than what's received, e.g. if you send a, |
| 8 |
you get b, send A you get B, and so forth. |
| 9 |
|
| 10 |
The circuit: |
| 11 |
- none |
| 12 |
|
| 13 |
created 21 Oct 2011 |
| 14 |
modified 27 Mar 2012 |
| 15 |
by Tom Igoe |
| 16 |
|
| 17 |
This example code is in the public domain. |
| 18 |
|
| 19 |
https://www.arduino.cc/en/Tutorial/BuiltInExamples/KeyboardSerial |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "Keyboard.h" |
| 23 |
|
| 24 |
void setup() { |
| 25 |
// open the serial port: |
| 26 |
Serial.begin(9600); |
| 27 |
// initialize control over the keyboard: |
| 28 |
Keyboard.begin(); |
| 29 |
} |
| 30 |
|
| 31 |
void loop() { |
| 32 |
// check for incoming serial data: |
| 33 |
if (Serial.available() > 0) { |
| 34 |
// read incoming serial data: |
| 35 |
char inChar = Serial.read(); |
| 36 |
// Type the next ASCII value from what you received: |
| 37 |
Keyboard.write(inChar + 1); |
| 38 |
} |
| 39 |
} |