Pico Macropad
Hello and welcome back!
Here's something useful: A macropad made completely from scratch using RP2040 Pico and a custom PCB was used, along with SMD tactile buttons and two custom PCBs, one for holding all the electronics components and the other as a mechanical board for keeping the 3D-printed switch in its place.
A macropad is a small keyboard-like device that is typically used to execute specific commands or macros. It usually consists of a set of programmable keys that can be assigned custom functions, macros, or shortcuts.
The six keys on the one I built currently have the functions W, S, A, D, Q, and E assigned to them; the seventh key is currently unassigned, but we can change its code to assign any function to these keys.
This article is about how this project was created and how you can make it in few easy steps. Let's get started.
Material Required
These are the materials used in this built-
- RPI Pico
- CUSTOM PCBs
- SMD Tactile switches
- 3D Printed Keys
- USB Cable
- M2 PCB Standoffs
- M2 Nuts and bolts
- Solder paste
3D Design
We began with a basic CAD design that includes two rectangular PCBs connected together with PCB standoffs at each edge, an SMD switch on the lower board, and a window in which a 3D-printed switch will be held.
A key press is registered when we press the 3D-printed switch, which steps the SMD button's knob and pushes it downward. This key press is detected by RPI PICO, which will be mounted on the lower board's bottom side.
Both the TOP and BOTTOM PCBs were modelled, and their layout was exported as a DWG file for use in PCB Cad software during construction.
PCB Design
The PCB design is very straightforward; we add a PICO with seven buttons and wire up each button to a different GPIO (from 0 to 6); the other end of the switch is wired up to GND.
When a button is pressed, every I/O connected to a switch is pulled down to GND because buttons are set up in pulldown mode.
With this schematic and the DWG file exported from Fusion360, the bottom board is first modeled.
Pico is placed on the bottom side, and all SMD buttons are placed on the top side.
As for the TOP PCB, we don't have to place any components in it; it's completely a mechanical board, so we use the DWG file from Fusion360 and make a PCB with a window for the 3D-printed switch in it.
We add random patterns to the top silkscreen to improve the top board's aesthetic, which will generally look cool.
PCBWAY
After I completed the PCB, I generated the Gerber data, which was then sent to PCBWAY for samples. An order was placed for both PCBs with white soldermask and black silkscreen, which look pretty cool in general.
I received PCBs within a week, and they were excellent, as expected.
I love the quality of PCBs made by PCBWAY. There are other manufacturers available, but their service is always on another level.
Check out PCBWay for getting great PCB service at less cost.
PCB Assembly
- The first step is to apply solder paste to each component pad.
- We then used an ESD tweezer to carefully pick and place all the SMD switches in their assigned places one by one.
- Next, we carefully lifted the whole circuit board and place it on my DIY Mini Hotplate which is also homemade just like this project. After a little time, when the hotplate reaches the temperature where the solder paste is melting, all of the components will be soldered using this hot reflow process.
- After installing the switches on the top side, we attach the RPI Pico to its position by applying solder paste to the Pico Pads on the bottom side.
- The solder paste is then heated with a hot air reflow gun before Pico is soldered in its place.
- PCB assembly is now completed.
Mechanical Assembly
- The 3D-printed switches, top-layer PCB, bottom-assembled PCB, and M2 PCB standoffs must all be gathered before beginning the mechanical assembly.
- We begin by attaching M2 PCB standoffs to the bottom PCB, which is where all of the electronic components are located. With the help of these standoffs, we can add the top layer on top of the bottom layer while maintaining the position of the 3D-printed switches.
- Then, using an M2 bolt and PCB standoffs, we attach 3D-printed switches to the top PCB before attaching them to the bottom PCB.
- Macropad assembly is now
CODE
Here's the code used in this built-
#include <Keyboard.h> int buttonPin0 = 0; // Set a button to any pin int buttonPin1 = 1; // Set a button to any pin int buttonPin2 = 2; // Set a button to any pin int buttonPin3 = 3; // Set a button to any pin int buttonPin4 = 4; // Set a button to any pin int buttonPin5 = 5; // Set a button to any pin void setup() { pinMode(buttonPin0, INPUT_PULLUP); pinMode(buttonPin1, INPUT_PULLUP); pinMode(buttonPin2, INPUT_PULLUP); pinMode(buttonPin3, INPUT_PULLUP); pinMode(buttonPin4, INPUT_PULLUP); pinMode(buttonPin5, INPUT_PULLUP); digitalWrite(buttonPin0, HIGH); digitalWrite(buttonPin1, HIGH); digitalWrite(buttonPin2, HIGH); digitalWrite(buttonPin3, HIGH); digitalWrite(buttonPin4, HIGH); digitalWrite(buttonPin5, HIGH); } void loop() { if (digitalRead(buttonPin0) == 0) // if the button goes low { Keyboard.write('q'); // send a 'z' to the computer via Keyboard HID delay(1); } if (digitalRead(buttonPin1) == 0) // if the button goes low { Keyboard.write('w'); // send a 'z' to the computer via Keyboard HID delay(1); } if (digitalRead(buttonPin2) == 0) // if the button goes low { Keyboard.write('e'); // send a 'z' to the computer via Keyboard HID delay(1); } if (digitalRead(buttonPin3) == 0) // if the button goes low { Keyboard.write('a'); // send a 'z' to the computer via Keyboard HID delay(1); } if (digitalRead(buttonPin4) == 0) // if the button goes low { Keyboard.write('s'); // send a 'z' to the computer via Keyboard HID delay(1); } if (digitalRead(buttonPin5) == 0) // if the button goes low { Keyboard.write('d'); // send a 'z' to the computer via Keyboard HID delay(1); } }
This is a simple code that uses the keyboard library for Arduino devices that have HID functionality.
RESULT
By first pressing the bootsel button and then inserting the USB into the Pico, we upload the sketch into the device.
After uploading the sketch, we can check the Macropad Keyboard's functionality by opening any text editor.
I started up Halo 2 and began using the custom macropad to play the game in extreme hard mode.
The keyboard is quicker and more responsive than the Macropad, but the code must be corrected so that it can be used properly in games.
That's about all I can say: It worked.
We can edit the code and assign shortcut key commands to each button, like Ctrl + C and Ctrl + V.
If you are into HID-related projects, then check out my previous work with PICO and Arduino Micro.
https://www.hackster.io/Arnov_Sharma_makes/arduino-game-controller-for-nes-and-gba-84c89b
https://www.hackster.io/Arnov_Sharma_makes/raspberry-pi-pico-as-hid-mouse-370827
This is it for today folks, leave a comment if you need help regarding this project.
Special thanks to PCBWAY for providing components that I've used in this project, check them out for getting all sorts of PCB or PCBA-related services for less cost.
Thanks and I will be back with a new project soon.
#include <Keyboard.h>
int buttonPin0 = 0; // Set a button to any pin
int buttonPin1 = 1; // Set a button to any pin
int buttonPin2 = 2; // Set a button to any pin
int buttonPin3 = 3; // Set a button to any pin
int buttonPin4 = 4; // Set a button to any pin
int buttonPin5 = 5; // Set a button to any pin
void setup()
{
pinMode(buttonPin0, INPUT_PULLUP);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
pinMode(buttonPin4, INPUT_PULLUP);
pinMode(buttonPin5, INPUT_PULLUP);
digitalWrite(buttonPin0, HIGH);
digitalWrite(buttonPin1, HIGH);
digitalWrite(buttonPin2, HIGH);
digitalWrite(buttonPin3, HIGH);
digitalWrite(buttonPin4, HIGH);
digitalWrite(buttonPin5, HIGH);
}
void loop()
{
if (digitalRead(buttonPin0) == 0) // if the button goes low
{
Keyboard.write('q'); // send a 'z' to the computer via Keyboard HID
delay(1); // delay so there aren't a kajillion z's
}
if (digitalRead(buttonPin1) == 0) // if the button goes low
{
Keyboard.write('w'); // send a 'z' to the computer via Keyboard HID
delay(1); // delay so there aren't a kajillion z's
}
if (digitalRead(buttonPin2) == 0) // if the button goes low
{
Keyboard.write('e'); // send a 'z' to the computer via Keyboard HID
delay(1); // delay so there aren't a kajillion z's
}
if (digitalRead(buttonPin3) == 0) // if the button goes low
{
Keyboard.write('a'); // send a 'z' to the computer via Keyboard HID
delay(1); // delay so there aren't a kajillion z's
}
if (digitalRead(buttonPin4) == 0) // if the button goes low
{
Keyboard.write('s'); // send a 'z' to the computer via Keyboard HID
delay(1); // delay so there aren't a kajillion z's
}
if (digitalRead(buttonPin5) == 0) // if the button goes low
{
Keyboard.write('d'); // send a 'z' to the computer via Keyboard HID
delay(1); // delay so there aren't a kajillion z's
}
}
Pico Macropad
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(2)
- Engineer Oct 01,2024
- ugur tezer Jan 07,2024
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Arnov Arnov sharma
- WALKPi PCB Version Greetings everyone and welcome back, This is the WalkPi, a homebrew audio player that plays music fr...
- Delete Button XL Greetings everyone and welcome back, and here's something fun and useful.In essence, the Delete Butt...
- Arduino Retro Game Controller Greetings everyone and welcome back. Here's something fun.The Arduino Retro Game Controller was buil...
- Super Power Buck Converter Greetings everyone and welcome back!Here's something powerful, The SUPER POWER BUCK CONVERTER BOARD ...
- Pocket Temp Meter Greetings and welcome back.So here's something portable and useful: the Pocket TEMP Meter project.As...
- Pico Powered DC Fan Driver Hello everyone and welcome back.So here's something cool: a 5V to 12V DC motor driver based around a...
- Mini Solar Light Project with a Twist Greetings.This is the Cube Light, a Small and compact cube-shaped emergency solar light that boasts ...
- PALPi V5 Handheld Retro Game Console Hey, Guys what's up?So this is PALPi which is a Raspberry Pi Zero W Based Handheld Retro Game Consol...
- DIY Thermometer with TTGO T Display and DS18B20 Greetings.So this is the DIY Thermometer made entirely from scratch using a TTGO T display board and...
- Motion Trigger Circuit with and without Microcontroller GreetingsHere's a tutorial on how to use an HC-SR505 PIR Module with and without a microcontroller t...
- Motor Driver Board Atmega328PU and HC01 Hey, what's up folks here's something super cool and useful if you're making a basic Robot Setup, A ...
- Power Block Hey Everyone what's up!So this is Power block, a DIY UPS that can be used to power a bunch of 5V Ope...
- Goku PCB Badge V2 Hey everyone what's up!So here's something SUPER cool, A PCB Board themed after Goku from Dragon Bal...
- RGB Mixinator V2 Hey Everyone how you doin!So here's a fun little project that utilizes an Arduino Nano, THE MIXINATO...
- Gengar PCB Art Hey guys and how you doing!So this is the GENGAR PCB Badge or a Blinky Board which is based around 5...
- R2D2 Mini Edition So here's something special, A Mini R2D2 PCB that speaks ASTROMECH.Astromech is a fictional language...
- C-3PO Blinky Board Hey guys and how you doing!So this is the C3P0 PCB Badge or a Blinky Board which is based around 555...
- WALKPi Breadboard Version Greetings everyone and welcome back, Here's something loud and musical.Similar to a traditional walk...
-
-
-
-
-
-
X-mas ball, Now with ANIMATED LIGHTS!
108 4 7 -
-
-
-
RC radial engine spark plug heater
29 0 0 -
-