Learning Examples | Foundations | Hacking | Links
Examples > Keyboard Library
This example listens for a byte coming from the serial port. When received, the board sends a keystroke back to the computer. The sent keystroke is one higher than what is received, so if you send an "a" from the serial monitor, you'll receive a "b" from the Leonardo (or Due). A "1" will return a "2" and so on.
NB: When you use the Keyboard.print() command, the Arduino takes over your computer's keyboard! To insure you don't lose control of your computer while running a sketch with this function, make sure to set up a reliable control system before you call Keyboard.print(). This sketch is designed to only send a Keyboard command after the Leonardo has received a byte over the serial port.
Hardware Required
Software Required
Circuit
Connect your board to your computer with a micro-USB cable.
Once programmed, open your serial monitor and send a byte. The Arduino will reply with a keystroke that is one number higher.
image developed using Fritzing. For more circuit examples, see the Fritzing project page
Code
See Also