How to use an Arduino Keyboard

Keyboard is always a key element in any kind of system, therefore Arduino has got its own keyboard that can be attached as all the other sensors, so you can use them in your solution. This guide provides you some useful information about the working method of an Arduino Keyboard and a step by step guide about how you can use the keyboard with your Ozeki 10. So, let's start right now.

What is an Arduino Keyboard?

Keypads allow users to input data while a program is running. A keypad is often needed to provide input to an Arduino system, and membrane-type keypads are an economical solution for many applications. They are quite thin and can easily be mounted wherever they are needed.

How does an Arduino Keyboard work?

The wires of the Adruino Keyboard represent a column or a row on the keyboard. On a 3x4 keyboard the order from left to right is R1, R2, R3, R4, C1, C2, C3, where R means row and C means column. So, you need to connect each wire to a digital input on the Arduino (Figure 1).

Pressing a button will short one of the row outputs to one of the column outputs. From this information, the Arduino can determine which button was pressed. For example, when key 1 is pressed, column 1 and row 1 are shorted. The Arduino will detect that and input a 1 to the program.

Arduino Keyboard wiring diagram

wiring diagram of arduino keyboard
Figure 1 - Wiring diagram of Arduino Keyboard

How to use an Arduino Keyboard in Ozeki

Keyboard controller connections guarantee that all of the pressed keys are forwarded to a selected connection in your Ozeki software. The supported MPR121 capacitive touch keypad has 12 buttons, which are numbers from 0 to 9 plus * and #. For the proper wiring diagrams, you can check the supported boards below in 'Step 1'. To use the Arduino Keyboard in Ozeki, you first need to download Ozeki Robot Developer. Ozeki Robot Developer will install the Arduino libraries needed to use this sensor efficiently.

Download Ozeki Robot Developer

download button

After Ozeki Robot developer is installed, you need to upload the Keyboard control code to your Arduino. You can find the code and download instructions on the following pages. The upload process includes two steps: first you need to format the EEPROM of the arduino, then you need to upload the control code. The procedure is very simple, it only takes a few seconds.

Upload the Keyboard code to Arduino Uno
Upload the Keyboard code to Arduino Mega 2560
Upload the Keyboard code to Arduino Nano
Upload the Keyboard code to Ozeki Matrix
Upload the Keyboard code to Raspberry Pi

The arduino keyboard and Ozeki will communicate over the USB port using the Ozeki Keyboard protocol. This protocol makes it possible for you to use the keyboard directly on your PC. You will be able to control this keyboard through the web based user interface or you will be able to communicate with it using Ozeki Chat. You can read more about chat control on the following page.

How to communicate with the Keyboard using chat

It is important to understand chat control, because when you build a robot, the way you wish to control this keyboard is by sending and receiving messages. If you open the Ozeki Robot Developer app, you will see, who you can write a C#.Net program to work with this keyboard.

Connection steps

  1. Use the wiring diagram to connect the keyboard to the Arduino
  2. Attach the Arduino board to your PC
  3. Check the COM ports to make sure your Arduino is connected
  4. Open the Arduino application on your computer
  5. Upload the example code to the Arduino
  6. Type https://localhost:9515 in your browser to open Ozeki 10
  7. Choose the connection of the Arduino keyboard
  8. Press any button on the keyboard to test it

System overview

The system we suggest consists of an Arduino keyboard, that is wired to the analog port of your Arduino. The Arduino will be responsible for reading data from this device in real-time. The brain of the system will be running on a PC (Figure 2). On the PC, Ozeki 10 will be able to manage the communication. You can easily run Ozeki 10 using a webbrowser

system config of the keyboard connected to pc
Figure 2 - System configuration of keyboard connecting to PC using Arduino

Prerequisites

  • MPR121 capacitive keyboard
  • Ozeki 10 installed on your computer
  • Programmable board (Arduino Mega/Nano/Uno, Ozeki Display Modul or Raspberry Pi)
  • USB cable is needed between Arduino Mega/Nano/Uno, Ozeki Display Modul and your computer

Step 1 - Wire the keyboard to your Arduino

You can see how to wire the MPR121 capacitive keyboard
to any of the following boards:

After wiring, please plug the board to your computer!

Upload code to the microcontroller

(Here is the code to upload)

Step 3 - Start Ozeki 10 to try the keyboard

Step 4 - Configure your keyboard in Ozeki 10

To configure your keyboard (attached to your Arduino) in Ozeki 10, that is installed on your computer, you need to open the graphical user interface (GUI) of Ozeki 10. You can open the GUI by entering the URL of the computer into your webbrowser. For example, if our PC has an IP address of 192.168.1.5, we would enter http://192.168.1.5:9513 into our webbrowser.

Step 5 - Understand the keyboard protocol

The Keyboard Controller can communicate with Ozeki through the following protocol.

References:
https://www.allaboutcircuits.com
https://www.circuitbasics.com

More information