From a587425e90590e9e82af055c3c0f292a5e6d70ac Mon Sep 17 00:00:00 2001 From: nnaka1 Date: Sun, 1 Mar 2020 23:16:59 -0500 Subject: [PATCH] Add Keyboard Serial example from arduino.cc --- examples/Serial/Serial.ino | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 examples/Serial/Serial.ino diff --git a/examples/Serial/Serial.ino b/examples/Serial/Serial.ino new file mode 100644 index 0000000..72d9ddd --- /dev/null +++ b/examples/Serial/Serial.ino @@ -0,0 +1,39 @@ +/* + Keyboard test + + For the Arduino Leonardo, Micro or Due + + 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 + modified 27 Mar 2012 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/KeyboardSerial +*/ + +#include "Keyboard.h" + +void setup() { + // open the serial port: + Serial.begin(9600); + // initialize control over the keyboard: + Keyboard.begin(); +} + +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); + } +}