Play a melody on the piezo
Play the notes of a scale on a passive piezo connected through 100 ohms to D8.
Play the notes of a scale on a passive piezo connected through 100 ohms to D8.
Use the Uno R3 Learning Kit. Build with power disconnected, check the labelled connections, then upload the supplied sketch. Drag or zoom the 3D model to inspect it from any angle.
Step 1 — Watch the complete build
Press Play for the narrated build. You can rotate and zoom the model while it plays, or follow the individual steps below.
Loading assembly…
Keep U S B disconnected while you build. On this breadboard, each group of five holes shares a connection; the centre channel separates the two halves. You can drag the 3D view to look around. Connect Arduino ground to the ground rail. Add the Piezo speaker. Its pin1 lead goes into column 10 row E; the highlights show the remaining holes. Add the 100 ohms resistor. Its Pin 0 lead goes into column 18 row H; the highlights show the remaining holes. Connect Arduino digital pin 8 to one end of the resistor. Connect the other end of the resistor to the Piezo speaker’s pin1 pin. Connect the Piezo speaker’s pin2 pin to the ground rail. Check all wiring. Connect the square U S B-B plug to the Uno and the U S B-A plug to your computer. Use Verify and Upload in the code editor below.
Step 2 — Understand the breadboard
Keep USB disconnected while you build. On this breadboard, each group of five holes shares a connection; the centre channel separates the two halves. You can drag the 3D view to look around.
Loading assembly…
Keep U S B disconnected while you build. On this breadboard, each group of five holes shares a connection; the centre channel separates the two halves. You can drag the 3D view to look around.
Step 3 — Connect Uno GND → T- rail 1
Connect Arduino ground to the ground rail.
| Connect | To |
|---|---|
| Uno GND | T- rail 1 |
Loading assembly…
Connect Arduino ground to the ground rail.
Step 4 — Place Piezo speaker
Add the Piezo speaker. Its pin1 lead goes into column 10 row E; the highlights show the remaining holes.
Exact breadboard holes
- piezo · pin1 → column 10 row E
- piezo · pin2 → column 11 row E
Loading assembly…
Add the Piezo speaker. Its pin1 lead goes into column 10 row E; the highlights show the remaining holes.
Step 5 — Place 100 Ω resistor
Add the 100 Ω resistor. Its Pin 0 lead goes into column 18 row H; the highlights show the remaining holes.
Exact breadboard holes
- r · Pin 0 → column 18 row H
- r · Pin 1 → column 22 row H
Loading assembly…
Add the 100 ohms resistor. Its Pin 0 lead goes into column 18 row H; the highlights show the remaining holes.
Step 6 — Connect Uno D8 → column 18 row J
Connect Arduino digital pin 8 to one end of the resistor.
| Connect | To |
|---|---|
| Uno D8 | column 18 row J |
Loading assembly…
Connect Arduino digital pin 8 to one end of the resistor.
Step 7 — Connect column 22 row J → column 10 row A
Connect the other end of the resistor to the Piezo speaker’s pin1 pin.
| Connect | To |
|---|---|
| column 22 row J | column 10 row A |
Loading assembly…
Connect the other end of the resistor to the Piezo speaker’s pin1 pin.
Step 8 — Connect column 11 row A → T- rail 11
Connect the Piezo speaker’s pin2 pin to the ground rail.
| Connect | To |
|---|---|
| column 11 row A | T- rail 11 |
Loading assembly…
Connect the Piezo speaker’s pin2 pin to the ground rail.
Step 9 — Place USB-A to USB-B cable · Uno
Check all wiring. Connect the square USB-B plug to the Uno and the USB-A plug to your computer. Use Verify and Upload in the code editor below.
Loading assembly…
Check all wiring. Connect the square U S B-B plug to the Uno and the U S B-A plug to your computer. Use Verify and Upload in the code editor below.
Step 10 — Program your Uno
Choose Arduino Uno. Verify, pair the board and Upload this sketch. Keep USB connected. Play the notes of a scale on a passive piezo connected through 100 ohms to D8.
Step 11 — Try it and troubleshoot
The pitch rises through an octave. Change the duration to alter the rhythm.
If it does not work
A self-oscillating active buzzer produces one pitch rather than a scale. Confirm the kit part is passive; never substitute a low-impedance loudspeaker directly on a GPIO.
Parts List
Required Parts (1)
Use the components named in this tutorial. A computer and any additional power supply are not included.
x1
$64.70
In stockProject Summary
1 part total
Unavailable items will be skipped