Search

Ardu Keyboard

About the project

Macro Keyboard based on ATmega328p

Project info

Difficulty: Easy

Platforms: Arduino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Push-button Power Switch Breakout Push-button Power Switch Breakout x 10
Usb A/micro Cable - 2m Usb A/micro Cable - 2m x 1
Sparkfun Serial Basic Breakout - Ch340c And Usb-c Sparkfun Serial Basic Breakout - Ch340c And Usb-c USB to TTL converter IC x 1
Adafruit Feather 328p - Atmega328p 3.3v @ 8 Mhz Adafruit Feather 328p - Atmega328p 3.3v @ 8 Mhz Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers x 1

Software apps and online services

Arduino IDE Arduino IDE
Python Python

Story

Keyboards are one of the most important input device for a computer. A standard keyboard has more than 100 different keys for different purposes. Yet sometimes it feels like it'd be great if there're some programmable buttons to execute certain commands or a particular set of key combination. Keeping that in mind I have designed this Ardu-Keyboard, a programmable macro keyboard based on popular atmega328p microcontroller. It has 9 push buttons connected in a 3 by 3 matrix format. Apart from that it has atmega328p DIP IC in bare minimum configuration, a USB 2 point 0 male connector and CH340C USB to TTL converted ic, to talk to the microcontroller over USB.

Details

Keyboards are one of the most important input device for a computer. A standard keyboard has more than 100 different keys for different purposes. Yet sometimes it feels like it'd be great if there're some programmable buttons to execute certain commands or a particular set of key combination. Keeping that in mind I have designed this Ardu-Keyboard, a programmable macro keyboard based on popular Atmega328p microcontroller. It has 9 push buttons connected in a 3 by 3 matrix format. Apart from that it has Atmega328p DIP IC in bare minimum configuration, a USB 2.0 male connector and CH340C USB to TTL converted IC, to talk to the microcontroller over USB. 

we need to make this board acts like a keyboard. Now Arduino uno or Atmega328p doesn't support HID out of the box. So how do we do that? Well there's a method that makes the Arduino as a HID device. But that involves stuffs like flashing firmwares, but I don't wanted to get into that much complexity. But if you want you can read more about it in this documentation

Now, the method I'm going to use is easier than this, and it has more flexibility over that method. I'll talk about that in a moment, but first let's see, what are we talking about. First we need to include the keypad library, for the matrix keypad. My keypad has 3 rows and 3 columns. then I created a keymap for the buttons. Next I defined the pin numbers, connected to the keypad matrix. then I initialize an instance of class, New Keypad. After that I defined the LED pin. In the setup section, we first initialize serial connection with 9600 brodrate. then we define the LED pin as output. in the loop section we simply read the keypad value, and print it on the serial monitor. 

But at this point you might ask this only prints the key values in the serial monitor. And we need to change it to keystrokes. This is where python comes to rescue. You need to have python installed in your system. Also you'll need this library, PyAutoGUI to have control over keyboard and mouse. Open up the python terminal. First we need to import the necessary libraries, which are serial to access serial ports, time to set delays and intervals. And obviously PyAutoGUI. Once that was we'll define the COM port and serial Brodrate. Next we'll read the serial data and store it into a variable. Now all is left to do is set the key commands accordingly. Then save the file and hit run. At this point if you press the button on the Ardu Keyboard you can see it in action. Now the great thing about this setup is that you don't need to reprogram the Arduino everytime you want to change the key commands. Since we are working with the serial values so by modifying the python script we can use the very same board in different platforms. This will certainly help you in programs like Photoshop or any other editing software where you often need various keyboard shortcuts. Possibilities are endless. 

Instructions

Step 1

Code

GitHub

Credits

Photo of ElectroPoint

ElectroPoint

Electronics Engineer, Maker, YouTuber

   

Leave your feedback...