Check out Prusa's Black Friday Deals. Only valid until December 3rd!

Arduino Uno Keypad

A simple keypad using and Arduino Uno, 3 rotary encoders and 3 buttons.
14
44
0
567
updated June 18, 2024

Description

PDF

This keypad uses :

  • Arduino Uno
  • 3 rotary encoders, with a rectangular base 16mm wide (I repurposed mine from a broken amplifier)
  • 3 buttons 9mm wide square base (the ones that usually come in Arduino kits)
  • a 5mm LED
  • Optionally a slide button to have to switchable modes (6mm x 20mm, quite common small buttons found in many gadgets, with 2 mounting holes, 15mm apart)
  • 3 x 10K ohms resistors (or 4 if you want the modes switch) for the buttons
  • 220 ohms resistors for the led
  • 8 x M3 nuts
  • 2 x M3x20mm
  • 6 x M3x8mm
  • 2x M4 nuts
  • 2x M4x10mm
  • some kind of weight, I used a 38mm x 21mm x 4mm piece of cast steel from an old amp but you could use washers or cut a piece of steel to size.

I have printed all of the files with my Prusa I3 MK2.5S and a 0.6mm wide nozzle with 0.25mm layer heights (the files are pretty easy to print and only the top part requires supports.

The keypad uses Serial communications to send keypress and knob turns that are then received by a python code that has to run in the background (you can set it up to automatically launch upon logging in).

The Arduino code is pretty simple and I have included it in the files (I have not programmed the modes switch but it should be pretty easy to add).

The python code uses the Pyserial library to read the informations from the serial bus (https://pyserial.readthedocs.io/en/latest/pyserial.html#installation) and the pyautogui library to register the keypresses (https://pyautogui.readthedocs.io/en/latest/install.html).

Here is the code I have used (the two knobs at the bottom are used to get 2 speeds of mouse scrolling and the top one is a volume knob, the buttons are function keys.

import serial
import pyautogui

arduino = serial.Serial("COM4", 9600, timeout=.1)
while True:
   data = arduino.readline()
   if data != None :
       dataList = data.decode("ascii").split("_")
       last = 0
       for word in dataList :
           if word == "volUp" : pyautogui.press('volumeup')
           elif word == "volDo": pyautogui.press('volumedown')
           elif word == "en1Up" : pyautogui.scroll(50)
           elif word == "en1Do" : pyautogui.scroll(-50)
           elif word == "en2Up" : pyautogui.scroll(500)
           elif word == "en2Do" : pyautogui.scroll(-500)
           elif word == "bu1": pyautogui.press('f1')
           elif word == "bu2": pyautogui.press('f2')
           elif word == "bu3": pyautogui.press('f3')

 

The keypad works relatively well though there are sometimes weird bugs that I haven't been able to solve.. Since I built the entire keypad with parts I already had lying around I am quite happy with the result.

Tags



Model origin

The author marked this model as their own original creation.

License