The connections are as follows:
- VCC on the HC-SR04 to VOUT on the CPX
- TRIG on the HC-SR04 to A2 on the CPX
- ECHO on the HC-SR04 to voltage divider (one end of the two 10k resistors)
- Divided voltage (other end of the two resistors) to A1 on CPX
- GND on the HC-SR04 to GND on the CPX
- Also connect a wire from between the two resistors to GND on the CPX
Speaker + Amplifier:
- PAM8302 A+ to CPX A0
- PAM8302 A- to CPX GND
- PAM8302 Vin to CPX Vout
- PAM8302 GND to CPX GND
- Speaker to PAM8302 output pins (wire color/order doesnt matter)
Start by soldering four wires to the HC-SR04 Distance Sensor. Make your wires long enough to reach from the inside bottom of your pumpkin to the holes you cut for the sensor. For use in future pumpkins, that may be larger, give yourself a little extra length.
The Echo pin on the sensor outputs a 5v signal, but the Circuit Playground Express (like many microcontrollers) is a 3.3V device. This means you'll need to divide the voltage of the Echo pin with two 10k resistors. For a more in-depth explanation of this setup, check out Kevin Walters' guide on using this sensor with a Circuit Playground Express.
Twist the two resistors together and solder the twist, then trim the wires to about 1 cm long. Be careful not to bend the wires back and forth too much, or they will break.
Solder wires to the resistors as shown. The white wire in this image connects to the Echo pin on the HC-SR04. The green and black wires will be soldered to the Circuit Playground Express in the next step.
Cover each connection with heat shrink tubing, then cover the whole resistor assembly with a larger piece of heat shrink tubing.
Make sure that the two wires that will go to the Circuit Playground Express are pointing in the same direction.
Follow the circuit diagram to connect the sensor to the Circuit Playground express. Solder the wires as shown below.
In most cases, you'll need to extend the wires of your speaker to reach from the hole you cut in your pumpkin to the bottom of the pumpkin, where the Circuit Playground Express will be.
For permanent installation in a fake pumpkin: If your speaker will be inserted into its hole from the outside of the pumpkin, you'll need to feed it through this hole first before soldering it to the Circuit Playground Express.
For temporary installation in a real (or fake) pumpkin: To make it easy to move the whole project to a new pumpkin, add a 2-pin connector between the speaker and the CPX as shown.
Connect the speaker wires to the Circuit Playground Express. Since there is just one speaker in this project, it doesn't really matter which wire is positive and which is ground. Solder one wire to A0 and the other to GND on the CPX.
Plug the battery pack into your Circuit Playground Express (if locating inside) and carefully place the whole circuit inside your pumpkin. Slide the sensor into its holes and the speaker into its hole. If you kept the holes snug, the components should stay in place without additional help.
The Circuit Playground Express and battery pack will sit at the bottom of your project, and it can be helpful to stick the CPX to the battery pack with tape to keep it facing the front of the pumpkin. For a layer of diffusion, place a crumpled piece of white tissue paper or a paper towel in front of the Circuit Playground Express.
When everything is installed, just add batteries and you're ready to play with your Jack-o-Theremin!