The Unlimited Quote Box
This is a triangular prism of 1/8th in clear acrylic with capacitive touch tape sensors, that when tapped, send a message to the LCD display, as well as filling the interior LEDs with the morse code equivalents of the message, color coded with a specific emotion that GPT finds applicable to the message!
Once done, the project solely requires a power source and can keep and infinite steam of quotes flowing to you from the comfort of your desk with themes that you can effect as specified below!
Here is a working link to a quick demo!
Supplies
1) 1 Raspberry Pi Pico W
2) 2 Small Bread Boards
3) 1 LCD Screen 16x2
4) 2 Neo Pixel strands of 30 lights each
5) 1 Adafruit MPR121 Touchpad breakout board
6) 1 Potentiometer
7) 3 5.77x4 inch sheets of clear acrylic
8) 2 5.77 edge length equilateral clear acrylic triangles
9) 1 Roll of transfer tape
10) 15 Male to male jump cables
11) 4 Alligator to alligator clip cables
12) Chat GPT API Key (with credits in the account)
Step 1: Laser Cut Materials
First we will need to cut the physical housing for this is project
We will need:
3x 5.77x4in rectangles of clear acrylic (1/8th inch thickness)
2x 5.77 side length equilateral triangles of clear acrylic (1/8th inch thickness)
I was able to achieve this at the BC hatchery, so a big thank you to the for allowing the use of their equipment!
I designed them in Adobe Illustrator and there are built in tools for both.
Use the rectangle tool to make the 5.77x4in rectangles of clear acrylic.
Use the polygon tool set to 3 sides to make the 5.77 side length equilateral triangles with radius 6
Wiring the Pico to LEDS
I used 2 of the Neo Pixel strips (pictured above)
For both I took several steps to modify the neo pixels :
1) I cut the ends of the wires in order to make a more stable connections
2) I then stripped the last quarter inch of the wires
3) Following this, I soldered on one end of a male to male jumper cable to each of the wires
I then connected the 6 wires, the grounds for each, the 5v inputs for each, and the data for each to my PICO W mounted on a bread board.
In this step I personally used pins GP6 and GP8.
Know where you keep these, it is important as the GP input will begin to fill quite quickly.
We will be using these with the Adafruit_NeoPixel library in CircuitPython.
Wiring the MPR121 to the Pico W
Here we wish to use the very helpful existing I2C pins.
Yellow goes to GP5
Blue to GP4
Red to 5V
Black Ground
Keep in mind there are specific libraries we will need to with, the Adafruit_MPR121 library is essential on the PICO W when doing this in CircuitPython.
Here I will only use pads 1,2,3,4, where I used alligator to alligator clip wires to connect these pads to capacitive touch tape that will functions as our buttons later.
Wiring on Our LCD Screen
Some LCD screens come with I2C compatibility, unfortunately mine did not and had lead to the wiring being slightly painful.
I HIGHLY HIGHLY recommend keeping the LCD on a bread board and having wires going breadboard to breadboard to communicate with the Pico, LCDs are temperamental in my experience
We need to connect 11 of the 16 pins from the LCD screen to the Pico.
Keep in mind, while "backlight" is mentioned in many guides, we will not be assigning it a pin here.
For a great general guide to wiring the LCD, please see the attached link, it was a life saver.
The pins on these board have names, but are also labeled 1-16 which is how I will be referencing theme here
1 on the LCD goes to ground
2 on the LCD goes to 5V out
3 on the LCD goes to middle of the potentiometer (I will wire the rest of this in the next step)
4 on the LCD goes to GP16
5 on the LCD goes to ground
6 on the LCD goes to GP17
11 on the LCD goes to GP18
12 on the LCD goes to GP19
13 on the LCD goes to GP20
14 on the LCD goes to GP21
15 on the LCD goes to 5V out
16 on the LCD goes to ground
Note you need not follow this exactly however I recommend it as it makes board real-estate very tight and in this version all the data pins on the Pico side are near each other!
Wiring the Potentiometer
This can feel a weird thing to include in this build, but it can actually be essential, it adjusts the visibility of the LCD screen! Unless your LCD screen is already perfectly calibrated, then you'll want to include this part, as I learned the hard way.
It is also fairly simple as potentiometers of the basic kind come with 3 pins:
Left-most - I wired this to 3.3V Out (might be worth soldering male to male to this pin for security)
Center - We already wired a pin from the LCD here
Right-most - I wired this to ground (might be worth soldering male to male to this pin for security)
The Code
Here I will detail how my code works!
We use board, busio, adafruit_requests, wifi, socketpool, ssl, neopixel, time, adafruit_mpr121, adafruit_debouncer (Button), adafruit_character_lcd.character_lcd, and digitalio. All of these are Circuit python libraries with a great community and strong documentation.
To sketch my code there are 4 main parts. First, on button press, we send a request to Chat GPT for a quote, when Chat GPT returns the quote we move to the second step. The second part is display where the quote is displayed on screen and scrolled through with 0.75 seconded pauses before the letters advance. The thirds part is message processing. The Chat GPT message is then converted to a binary string using a morse code dictionary. In the final step we retrieve the color that Chat GPT packaged with the message, and we use the binary string to loop lights through the Neo Pixel strands in the color suggested by GPT to correlate to the sentiment of the quote. Then all is cleared and we may repeat.
To bring this into reality I put together several helper functions which I will include here:
This function demonstrates a way to organize the data going to GPT, and also demonstrates a reliable query and a way to modify what type of quotes may be generated in this project. This is the exact function I use to package my data each time and the exact context I used to generate my quotes.
When using the requests library in circuit python to talk to GPT, we must also upload some headers which I handle with the above function
The only other function is a beast which I will try to explain below
This is the function I will call to execute the entire process, it calls GPT, parses the data that GPT returns, isolates the color and the text that GPT returns, converts the text speech to morse code with a hard coded dictionary, convert the morse code to a binary string, uses loops and slices to pull this through the strand in a visually appealing way, and does this in the color GPT returns.
Some other useful code you may want to use as a resource:
Assembly!
Now we can assemble.
Use the rectangles and triangles to assemble a triangular prism. (super glue works great)
Wrap the Neo Pixel strips in a helix around the inside of the prism.
Use the open space in the center to tuck the breadboard, MPR121 board, potentiometer, and excess wiring.
Attach the LCD breadboard to the top of on of the prism's wall by the lid.
I suggest wrapping the walls of the prism with something opaque like transfer paper.
Gently thread the wires under the lid as you lower it on the completed product!
You can power either by running a wire out of the lid to a computer to tuck a power bank inside!