Pico Macropad

by Arnov Sharma in Circuits > Raspberry Pi

1791 Views, 20 Favorites, 0 Comments

Pico Macropad

Raspberry Pi Pico Macropad
19 (18).gif
20 (15).gif
16 (24).gif
IMG_20230325_210907.jpg
mac.jpg

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 Instructables is about how this project was created and how you can make it in few easy steps. Let's get started.

Supplies

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

01 (20).gif
Micropad v2.png
002.png
2Capture.JPG
Capture.JPG

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

sch_page-0001 (3).jpg
3Capture.JPG
4Capture.JPG

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

02 (24).gif
03 (22).gif

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

04 (23).gif
05 (23).gif
06 (24).gif
07 (23).gif
08 (24).gif
09 (26).gif
10 (22).gif
  • 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

11 (24).gif
12 (23).gif
13 (24).gif
14 (27).gif
15 (23).gif
  • 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

Raspberry Pi Pico Macropad
16 (24).gif
20 (15).gif

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.instructables.com/Raspberry-Pi-Pico-As-HID-Mouse/

https://www.instructables.com/Arduino-Game-Controller-for-NES-and-GBA/

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.