Week 3

Embedded Programming - The Paste Pal

← Back to home page

Overview

This week I built the Paste Pal, a small handheld controller that stores up to 8 different items on so I can copy and paste between them without losing anything. I soldered the board together myself (the microcontroller, resistor, and OLED screen), then worked step by step with AI (Claude) to write the code. Rather than just copying code, I used it to understand the different coding approaches and how variables are stored and changed as the program runs. Finally, I designed a holder from scratch so the Paste Pal sits on my desk ready to use.

Programming the Board (Arduino)

The first step was getting the Arduino IDE ready. I searched the Boards Manager for "pico" to install support for the RP2040 chip that the Seeed XIAO microcontroller uses.

Arduino Boards Manager search for pico

Here is the assembled QPAD attached to the computer via USB-C. You can see my work on the soldering here as well!

Soldered QPAD board plugged in over USB-C

With the board selected, I installed the Adafruit SSD1306 library for the OLED screen in order to allow for programming of the OLED screen.

Installing the Adafruit SSD1306 library

For my first sketch, I added some text and drew a rectangle while also configuring the screen properly.

First sketch printing text and drawing a rectangle

To learn the drawing commands, I read through the Adafruit GFX Graphics Library guide on how to program and manipulate their graphics.

Adafruit GFX Graphics Library guide

I then experimented with those commands myself, drawing a pixel, a circle outline, and a filled circle by changing the values and positions as directed by the library.

Code drawing a pixel and two circles

Here you can see the basic shapes I manually programmed via the Adafruit library.

OLED screen showing the drawn shapes

Next came the buttons. The Serial Plotter was used first to watch a live value coming off the board. This was a part of the step to connect the QPAD to the computer and register commands.

Serial Plotter showing one live value

Then I plotted all six touch pads (up, down, left, right, copy, and paste) at once to see how their readings behave. This was done in order to coordinate capacitance to button presses. This was an important baseline in order to ensure that button presses were registered properly.

Serial Plotter showing all six touch pads

I then programmed and verified operation of pressing, holding, and releasing the different buttons.

Serial Monitor showing button press, hold, and release events

Finally, the board acts as a keyboard to send shortcuts like Ctrl+C the way fingers would: hold Ctrl, press the letter, pause, and release. This one also taught me to watch my braces, since a missing one broke the whole sketch.

Code sending a Ctrl keyboard shortcut

Programming on the computer (Python)

To reach the computer's clipboard, a Python script running on the laptop is needed. I installed pyserial and pyperclip, then wrote a simple listener that reads each line the board sends over the serial port. This verified the correct commands were being received by the computer.

Python serial listener and library install

After switching to the correct port (COM5), the terminal showed "Board says:" followed by every button press and release.

Terminal showing button messages from the board

The real clipboard helper. The saved items are kept in a dictionary, where each slot number points to the saved text. When the board sends a command like "SAVE 3", it's split into the command and the slot number, and the script either saves what Windows just copied or loads it back.

Python clipboard helper code

Testing it: "Apple" saved to slot 1, "Bannana" to slot 2, then switching between them and loading each one back.

Terminal showing items saved to and loaded from slots

I added CLEAR and QUIT commands so the Paste Pal can empty a slot or shut the helper down (I removed this feature as it was awkward in practice).

Python code for the CLEAR and QUIT commands

To keep from wiping everything by accident, clearing all slots now needs two taps on the left button: the first asks the question and the second confirms it.

Code for the two-tap clear confirmation

Designing the Holder

For the holder I wanted to use heat-set inserts so the board could be screwed in and removed many times. I watched a Markforged video on how to install them.

Markforged video on installing heat-set inserts

I then ordered an M2 to M5 heat-set insert kit.

Heat-set insert kit listing

I started in Fusion 360 by sketching the board's outline and mounting holes, all dimensioned so the screws will line up with the board (The dimensions on the board work perfect the first time).

Fusion 360 sketch of the board outline and mounting holes

I moved the sketch up, rotated it, and extruded the two sketches together. Then extruded the outsides 2mm further for the board border.

Holder with the board pocket cut in

The holder is angled so the screen and buttons face up toward me when it's sitting on the desk.

Angled holder in Fusion 360

I then added a cutout in the middle for the components (prongs of OLED screen) on the back of the board, along with the four holes for the heat-set inserts.

Center cutout and insert holes

The finished design, with the edges filleted for a cleaner look and easier printing.

Finished holder design with filleted edges

The final print of the holder, fresh off the printer.

The printed red holder

I used a soldering iron for the inserts and was able to make a perfect fit on the first print.

Holder with heat-set inserts installed

I then assembled the full board and labeled the copy and paste buttons. Here is the final product!

The finished Paste Pal in its holder

Here is the Paste Pal in action!

AI use notated in the html

← Back to home