Piezo Buzzer — Making Music with Code
Generate different musical tones using a piezo buzzer and program a simple melody.
What students learn
Students learn about sound waves, frequency and pitch relationship, the tone() function, and using arrays to store melodies.
The science behind this experiment
- Sound is produced by vibrations at specific frequencies
- Higher frequency = higher pitch. A4 = 440 Hz is the standard tuning reference
- tone(pin, frequency, duration) generates a square wave at the given frequency
- Musical notes correspond to specific frequencies: C4=262Hz, D4=294Hz, E4=330Hz, etc.
Key relation: Musical notes: C4=262Hz, D4=294Hz, E4=330Hz, F4=349Hz, G4=392Hz, A4=440Hz, B4=494Hz, C5=523Hz
Equipment used
- Arduino Uno R3
- Breadboard
- 1x Piezo buzzer
- Jumper wires
Questions for students
- Why does a square wave from a buzzer sound different from the same note on a piano?
- How would you add a button to play different melodies?
What to expect
The buzzer plays individual tones and a recognizable melody (e.g., "Twinkle Twinkle Little Star"). Sound is produced by vibrations at specific frequencies. The tone() function generates these frequencies, and arrays organize notes into melodies.
Run this experiment in your classroom
This experiment is part of ATP Volta — a self-contained mobile science lab that turns an ordinary classroom into a working STEM laboratory, with over 200 experiments in physics, chemistry, biology, robotics and engineering. Gali, the AI tutor built into ATP Connect, guides students through each step and answers their questions at the bench.
See the ATP Volta mobile science labTalk to our team