- Arduino - Network Communication
- Arduino - Wireless Communication
- Arduino - Tone Library
- Arduino - Stepper Motor
- Arduino - Servo Motor
- Arduino - DC Motor
- Arduino - Connecting Switch
- Arduino - Ultrasonic Sensor
- Arduino - PIR Sensor
- Arduino - Water Detector / Sensor
- Arduino - Temperature Sensor
- Arduino - Humidity Sensor
- Arduino - Keyboard Serial
- Arduino - Mouse Button Control
- Arduino - Keyboard Message
- Arduino - Keyboard Logout
- Arduino - LED Bar Graph
- Arduino - Reading Analog Voltage
- Arduino - Fading LED
- Arduino - Blinking LED
- Arduino - Serial Peripheral Interface
- Arduino - Inter Integrated Circuit
- Arduino - Communication
- Arduino - Interrupts
- Arduino - Random Numbers
- Arduino - Pulse Width Modulation
- Arduino - Due & Zero
- Arduino - Trigonometric Functions
- Arduino - Math Library
- Arduino - Character Functions
- Arduino - Advanced I/O Function
- Arduino - I/O Functions
- Arduino - Arrays
- Arduino - Time
- Arduino - String Object
- Arduino - Strings
- Arduino - Functions
- Arduino - Loops
- Arduino - Control Statements
- Arduino - Operators
- Arduino - Variables & Constants
- Arduino - Data Types
- Arduino - Program Structure
- Arduino - Installation
- Arduino - Board Description
- Arduino - Overview
- Arduino - Home
Arduino Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Arduino - Keyboard Serial
This example pstens 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 will receive a "b" from the board connected to the computer. A "1" will return a "2" and so on.
Warning − When you use the Keyboard.print() command, the Leonardo, Micro or Due board takes over your computer s keyboard. To ensure you do not lose control of your computer while running a sketch with this function, set up a repable control system before you call Keyboard.print(). This sketch is designed to only send a Keyboard command after the board has received a byte over the serial port.
Components Required
You will need the following components −
1 × Arduino Leonardo, Micro, or Due board
Procedure
Just connect your board to the computer using USB cable.
Sketch
Open the Arduino IDE software on your computer. Coding in the Arduino language will control your circuit. Open a new sketch File by cpcking New.
Notes − You must include the keypad pbrary in your Arduino pbrary file. Copy and paste the keypad pbrary file inside the file with the name ‘pbraries’ highpghted with yellow color.
Arduino Code
/* 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 */ #include "Keyboard.h" void setup() { // open the serial port: Serial.begin(9600); // initiapze 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); } }
Code to Note
Once programed, open your serial monitor and send a byte. The board will reply with a keystroke, that is one number higher.
Result
The board will reply with a keystroke that is one number higher on Arduino IDE serial monitor when you send a byte.
Advertisements