The Sound (and Sight) of Music! Teaching Electronics with the STM32 Nucleo
By Michael Parks, P.E., Mouser Electronics
Licensed under CC BY-SA 4.0
The Build (Building the Electronics)
Conveniently all the components will fit on a single, small breadboard. The build is very straightforward. The first nine steps are used regardless if you are going to use the Nucleo or not. The final steps will vary depending if you desire to use the Nucleo or not. Option A will simply drive two LEDs without the Nucleo (using AA batteries instead of the Nucleo to power it.) Option B will require a computer to program the Nucleo and then perform the light show as we have programmed in our code. If you stop after implementing Option A, then you can still use the Nucleo for power.
Figure 9: Schematic of the STM32 Nucleo Sight and Sound open source hardware project. (NucleoLightSoundEducationSchematic.png)
Instructions: Print out the schematic as listed in the Resources section.
- Carefully place the op-amp favoring one end of the breadboard, but leave about 3 rows available on the end you choose. Be aware that each pin has a different purpose. The datasheet will show you what each pin does and how they interconnect internally. Notice that DIP ICs have a dot (either printed or a depression on the package) near pin 1. There also tends to be a small “U”-shaped depression towards the top of the chip, with pin 1 being to the left. I cannot stress enough the importance of buying an extra IC or two when ordering your parts. From bent pins that break off, to reversing Vcc and GND, once chips are broken there is no repair. Have a few extra on hand will give you peace of mind when experimenting with a design.
- Next place the trimpot so that the central wiper pin is connected to op amp pin 5, and that an outer pin of the trimpot connects to op amp pin 2. Recall, we are splitting out the left and right audio channel so we are going to repeat this for the other side of the op amp. This time, the central wiper pin is connected to op amp pin 10 and that an outer pin of the trimpot connects to op amp pin 13.
- Add the fixed resistor to each trimpot, with one end of the resistor attaching to the trimpots and the other to GND. Connect to the same outer pin of the trimpots that you used in step 2.
- Place the 3.5 mm audio jack onto the breadboard. Be sure to align the audio jack so each pin gets its own row on the breadboard.
- Connect pin 5 of the audio jack (tip, left channel) to pin 12 of the op amp.
- Connect pin 2 of the audio jack (ring, right channel) to pin 3 of the op amp.
- Connect pin 1 of the audio jack (sleeve, ground channel) to pin 11 of the op amp.
- Connect pin 6 of the op amp to pin 7 of the op amp chip. (This is the feedback loop)
- Connect pin 8 of the op amp to pin 9 of the op amp chip. (This is the feedback loop)
- Connect pin 1 of the op amp to pin 5 of the op amp.
- Connect pin 10 of the op amp to pin 14 of the op amp.
Continue on with at least Option A, which does not require code (but requires the Nucleo for its power source.) You can add Option B which controls many more LEDs and uses the MCU of the Nucleo and includes programming as included in the Software section.
Option A: LEDs driven by the output of the op amp
- Place a 100-ohm resistor, 220-ohm resistor, and a 0.1uF capacitor onto the board so that they all share a common node (the positive lead of the capacitor). Replace this 220-ohm resistor with the extra 100-ohm resistor if the LED isn’t bright enough.
- Connect the anode of the LEDs to the other end of the 220-ohm resistor.
- Connect the cathode of the LED, the negative lead of the capacitor and the free end of the 100-ohm resistor to a common node. Wire this node to ground.
- Repeat steps 1 through 3.
- Wire the output of op amp pin 7 to the common node shared by the two resistors and positive lead of the capacitor. This will show the intensity of the right channel.
- Wire the output of op amp pin 8 to the common node shared by the other two resistors and positive lead of the second capacitor. This will show the intensity of the left channel.
- Skip the software section if you do not continue to Option B.
Option B: LEDs driven by the Nucleo
- Place six 220-ohm resistors on the breadboard.
- Place six LEDs on the board, each one with the anode connected to one end of a 220-ohm resistor. The cathode of all LEDs can share a common ground.
- Take the free ends of the first three resistors and attach one to Nucleo pin D2, one to pin D3, and the last one to pin D4.
- Take the free ends of the remaining resistors and connect one to Nucleo pin D5, one to pin D6, and the last one to pin D7.
- Connect op amp pin 7 (output from the left channel) to Nucleo pin A0.
- Connect op amp pin 8 (output from the right channel) to Nucleo pin A1.
We would love to hear what you think about this project; please tell us in the comments section below.