Arduino Leonardo Keyboard



  • Arduino Tutorial
  • Arduino Function Libraries
  • Arduino Advanced
  • Arduino Projects
  • Arduino Sensors
  • Motor Control
  • Arduino And Sound
  1. Arduino Leonardo Keyboard Volume
  2. Arduino Leonardo Keyboard Enter
  3. Arduino Leonardo Keyboard Press
  4. Arduino Leonardo Keyboard Example
  5. Arduino Leonardo Keyboard Space
  6. Arduino Leonardo Keyboard Input

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.

  1. I am trying to use an Arduino Leonardo for keyboard emulation since that is one of its advertised features. I have been playing with the Leonardo and wrote a very simple sketch based off the Blink example.
  2. Connect the Bluetooth. The bluetooth adabter HC 05 use the serial comunication to connect to the.
  • Arduino Useful Resources
  • Selected Reading

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 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 reliable 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 clicking New.

Notes − You must include the keypad library in your Arduino library file. Copy and paste the keypad library file inside the file with the name ‘libraries’ highlighted with yellow color.

Arduino Code

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.

Keyestudio Leonardo R3 Development Board


  • 7Detailed Use with ARDUINO Software as follows
    • 7.1Step1| Download the Arduino IDE

Introduction

The keyestudio Leonardo is a microcontroller board based on the ATmega32u4 (datasheet ). It is an easy-to-use open source hardware.
It has 20 digital input/output pins (of which 7 can be used as PWM outputs), 12 analog inputs, a 16 MHz crystal oscillator, a micro USB connection, a power jack, an ICSP header, and a reset button.
It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. Note that ICSP (In-Circuit Serial Programming) header can not only program the firmware to Atmega32u4, but also be used as SPI communication interface.
The keyestudio Leonardo can be powered via the micro USB connection, or via an external power supply jack (DC 7-12V) or even with female headers Vin /GND (DC 7-12V).
The Leonardo differs from other Arduino boards using separate USB-Serial chip in that the ATmega32u4 has built-in USB communication, eliminating the need for a secondary processor. This allows the Leonardo to appear to a connected computer as a mouse and keyboard.


TECH SPECS

MicrocontrollerAtmega32u4
Operating Voltage5V
Input Voltage (recommended)DC7-12V
Digital I/O Pins20 (of which 7 provide PWM output)
PWM Digital I/O Pins7
Analog Input Pins12
DC Current per I/O Pin40 mA
DC Current for 3.3V Pin50 mA
Flash Memory32 KB (Atmega32u4) of which 4 KB used by bootloader
SRAM2.5 KB (ATmega32u4)
EEPROM1 KB (Atmega32u4)
Clock Speed16 MHz
LED_BUILTIND13


Details

  • PCB Dimensions: 71mm*54mm*15mm
  • Weight: 18.4g



Element and Interfaces

Button

Here is an explanation of what every element and interface of the board does:

Specialized Functions of Some Pins


Digital I/O pinsD0-D13 and A0-A5 (D18-D23); Note that if the digital pins are not enough, the ICSP pins can be used as digital pins. MISO (D14); SCK(D15); MOSI (D16).
Analog InputsA0-A5, A6-A11 (on digital pins 4, 6, 8, 9, 10, and 12). That is, D4 (A6)、D6 (A7)、D8 (A8)、D9 (A9)、D10 (A10) and D12 (A11).

Pins A0-A5 appear in the same locations as on the Uno; inputs A6-A11 are on digital i/o pins 4, 6, 8, 9, 10, and 12 respectively. Each analog input provide 10 bits of resolution (i.e. 1024 different values). By default the analog inputs measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function.

PWM (Pulse-Width Modulation)D3, D5, D6, D9, D10, D11 and D13. Provide 8-bit PWM output with the analogWrite() function.
External InterruptsD3 (interrupt 0); D2 (interrupt 1); D0 (interrupt 2), D1 (interrupt 3) and D7 (interrupt 4).

These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.

Serial communicationD0 (RX) and D1 (TX).
SPI communication
On the ICSP header.

These pins support SPI communication using the SPI library. Note: the SPI pins are not connected to any of the digital I/O pins as they are on the Uno. They are only available on the ICSP connector. This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the Leonardo's 6-pin ICSP header, the shield will not work.

AREFReference voltage for the analog inputs.

Used with analogReference(). Sometimes used to set the external reference voltage (0-5 volts) as the upper end of analog input pins.

IOREFThe voltage at which the i/o pins of the board are operating (i.e. VCC for the board).

This is 5V on the Leonardo. Used to configure the operating voltage of microcontroller.


Tips

  • Automatic (Software) Reset:

Rather then requiring a physical press of the reset button before an upload, the Arduino Nano is designed in a way that allows it to be reset by software running on a connected computer.

  • USB Overcurrent Protection:

The Leonardo has a resettable polyfuse that protects your computer's USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.


Detailed Use with ARDUINO Software as follows

Step1| Download the Arduino IDE

When you get the board, first you should install the Arduino software and driver.
We usually use the Windows software Arduino 1.5.6 version. You can download it from the link below:
https://www.arduino.cc/en/Main/OldSoftwareReleases#1.5.x
Or you can browse the ARDUINO website to download the latest version from this link, https://www.arduino.cc, pop up the following interface.

Then click the SOFTWARE on the browse bar, you will have two options ONLINE TOOLS and DOWNLOADS.

Click DOWNLOADS, it will appear the latest software version of ARDUINO 1.8.5 shown as below.

In this software page, on the right side you can see the version of development software for different operating systems. ARDUINO has a powerful compatibility. You should download the software that is compatible with the operating system of your computer.
We will take WINDOWS system as an example here. There are also two options under Windows system, one is installed version, the other is non-installed version. For simple installed version, first click Windows Installer, you will get the following page.

This way you just need to click JUST DOWNLOAD, then click the downloaded file to install it.
For non-installed version, first click Windows ZIP file, you will also get the pop-up interface as the above figure.
Click JUST DOWNLOAD, and when the ZIP file is downloaded well to your computer, you can directly unzip the file and click the icon of ARDUINO software to start it.


Installing Arduino (Windows)

Install Arduino with the exe. Installation package downloaded well.

Click“I Agree”to see the following interface.

Click “Next”. Pop up the interface below.

You can press Browse… to choose an installation path or directly type in the directory you want.
Then click “Install” to initiate installation.

Wait for the installing process, if appear the interface of Window Security, just continue to click Install to finish the installation.


Introduction for Arduino IDE Toolbar

Double-click the icon of Arduino software downloaded well, you will get the interface shown below.
(Note: if the Arduino software loads in the wrong language, you can change it in the preferences dialog. See the environment page for details.)
The functions of each button on the Toolbar are listed below:

Verify/CompileCheck the code for errors
UploadUpload the current Sketch to the Arduino
NewCreate a new blank Sketch
OpenShow a list of Sketches
SaveSave the current Sketch
Serial MonitorDisplay the serial data being sent from the Arduino


Step2| Installing the Driver

Installed well the Arduino, the next step is to install the driver. The Arduino folder contains both the Arduino program itself and the drivers that allow the Arduino to be connected to your computer with a USB cable.

In different systems, the driver installation is similar. Here we start to install the driver on the Win7 system.
Plug one end of your USB cable into the keyestudio Leonardo and the other into a USB socket on your computer.
When you connect the board to your computer at the first time, right click your “Computer” —>for “Properties”—> click the “Device manager”, under Other devices, you should see the “Arduino Leonardo”.

Then right-click on the Arduino Leonardo and select the top menu option (Update Driver Software...) shown as the figure below.

Then it will be prompted to either “Search Automatically for updated driver software” or “Browse my computer for driver software”. Shown as below. In this page, select “Browse my computer for driver software”.

After that, select the option to browse and navigate to the “drivers” folder.

Arduino Leonardo Keyboard Volume

Once the software has been installed, you will get a confirmation message. Installation completed, click “Close”.

Up to now, the driver is installed well. Then you can right click “Computer” —>“Properties”—>“Device manager”, you should see the device as the figure shown below.


Arduino Leonardo Keyboard Enter

Step3| Connect the board

Connect the Leonardo board to your computer using the USB cable. The power LED should go on.


Step4| Select the Arduino Board

Open the Arduino IDE, you’ll need to click the “Tools”, then select the Board that corresponds to your Arduino.

Arduino Leonardo Keyboard Press


Step5| Select your serial port

Select the serial device of the Arduino board from the Tools | Serial Port menu.
Note: to avoid errors, the COM Port should keep the same as the Ports shown on Device Manager.


Step6| Upload the Code

Below is an example code for displaying the Hello World!
Copy and paste the code to the Arduino environment IDE.


Then click verify button to check the errors. If compiling successfully, the message 'Done compiling.' will appear in the status bar.
After that, click the “Upload” button to upload the code. If the upload is successful, the message 'Done uploading.' will appear in the status bar.


Step7| Open the Serial Monitor

After that, click the button to open the serial monitor.
Then set the baud rate to 9600, enter an “R” and click Send, that is, the computer will send the character R. When the board receives it, you should see the RX led on the board flash once, and then D13 led flash once; when keyestudio Leonardo R3 board successfully sends 'Hello World!' to the computer, you should see the 'Hello World!' is showed on the monitor, and TX led on the board flash once.


Package Included

  • keyestudio Leonardo R3 board * 1pcs
  • Black micro USB cable 1m * 1pcs

Arduino Leonardo Keyboard Example



Resource Links

You might also want to look at:
the reference for the Arduino language;

Arduino Leonardo Keyboard Space

Download ARDUINO Software:
https://www.arduino.cc/en/Main/OldSoftwareReleases#1.5.x

Or download the software and driver from the link below:
https://drive.google.com/open?id=12D-JkXdNm03Qt4dlPQr3RP6OmgXqpvHc


Troubleshooting

If you have problems, please see the troubleshooting suggestions.


Arduino Leonardo Keyboard Input

Shop Now

Retrieved from 'http://wiki.keyestudio.com/index.php?title=Ks0248_keyestudio_Leonardo_R3_Development_Board&oldid=30452'