A Pro tip (but many of you are probably already amateur professionals): Before I connected anything to the shuttle, I put all my components (buttons, LEDs, Bluetooth speakers, RPi) on my sunroom table and tested, tested, tested … when a code is of course written! After working on fast prototype projects at work, you can never do enough testing 🙂
I chose the Raspberry Pi 3B + to be the brain of the outfit for four reasons:
- It has WiFi on board so I could download The .wav files I needed to play the sounds
- It has an SD card on board to save the files to
- It has built-in Bluetooth capability to interface with my Bluetooth speaker
- I had a pair that was low around QTH (that's the ham radio for home)
And I decided that the layout of the shuttle cockpit would have three buttons:
- Red button : control the LED headlights (turn them on and off)
- Green button : check the thrusters! It would not only turn on the LEDs in the thrusters but also play a NASA sound from an actual shuttle liftoff ̵
- Blue button : Cycle through 5 legitimate NASA sounds with each push button
The code I wrote was in Python and heavily used the GPIO library; it's in my GitHub repo. (Let me know if there are any problems) I chose this so that I could add event detections from button presses and disable the same discoveries when I wanted ( for example if my daughter pressed the thruster button and then immediately started beating the others – – because she is two – I did not want the other button actions to happen afterwards). I basically wanted callback functions while still monitoring for events; this is an example of several threads all happening thanks to the magic of the GPIO library.
I downloaded audio from a NASA website and drew what sounds cool: I found an excerpt from the JFK's about sending a man to the moon, "Houston we have a problem" sound, and a lot of countdowns and liftoffs . I will say that they downloaded as mp3 and so I found an online mp3 to wav file converter so I could play them via RPi. For speakers, I had a variety of Bluetooth speakers lying around, so it was a simple matter of choosing one.
When I started connecting, the items I had to hook up were:
- 3 buttons
- 5 LEDs (2 for the headlights, 3 for the thrusters)
I had the LEDs lying around like a friend from my ham radio club gave me about three years ago. With the risk of hoarding, I just knew I would find an application for them 🙂 For the thruster lights, I simply drilled a small hole in each thruster, tied a string to the lamps and then pulled the string through the hole and tied it on a piece of the frame somewhere. Then I unwound a length of red / black wire, soldered one end to the lamps and ran the other side all the way forward where the RPi would live. The headlights followed a similar procedure only if they were sitting on a small shelf I did for them. Finally, I had to plug in the buttons. These guys had four projections:
- 2 rods (power / ground) for the LEDs in the buttons themselves
- 2 projections (power / ground) to send voltage high (or low) at pressure
To make life easy on myself I soldered all the LED wires and LED ground wires together and drove them to the VCC and GND port on RPi. The last bit to deal with then was to figure out which wiring was on RPi. I found a port layout of RPi online (and the nice thing about the GPIO library is that you can reference the ports through physical ordering) and just started assigning positions in my Python script.
I used an old styrofoam container that my father-in-law's heart medication came in to house the buttons, RPi, battery and the rat of wires (this is something I need to be better at) that you can see in the pictures above . I couldn't think of anything better then. The battery was what I was most nervous about because I hoped RPi could boot from it AND had enough charge to run anything longer than 15 minutes ( Spoiler Alert: It worked great! After an hour outside with the shuttle trolley, I didn't even lose a dot for battery life)