
Using a Piezo Buzzer — SIK Circuit 11
Imiyalelo
Parts & Introduction
Parts & Introduction
A piezo buzzer converts electrical signals into sound. Using Arduino's built-in tone() function, you can play specific musical frequencies. This sketch plays a simple melody using character arrays for notes and integer arrays for timing.
Parts Needed
- 1x Arduino Uno + USB cable
- 1x Breadboard
- 1x Piezo Buzzer
- 3x Jumper Wires
Note Frequency Reference
| Note | Freq |
|---|---|
| c | 262 Hz |
| d | 294 Hz |
| e | 330 Hz |
| f | 349 Hz |
| g | 392 Hz |
| a | 440 Hz |
| b | 494 Hz |
| C | 523 Hz |
Izinto zokwakha zalesi sinyathelo:
SparkFun Inventor's Kit - V3.21 ikhithiAmathuluzi adingekayo:
Ikhompyutha Ene-Arduino IDEHardware Hookup
Hardware Hookup
Wiring Instructions
- Place the piezo buzzer in the breadboard. It has two pins — one marked with "+".
- Connect the positive pin (+) to Arduino Digital Pin 9 (PWM).
- Connect the negative pin to GND.
Tip: If the buzzer doesn't fit easily, try rotating it slightly to align with diagonal breadboard holes.
Izinto zokwakha zalesi sinyathelo:
Ibhuza le-piezo1 ucezu
Izintambo Zokuxhuma2 izicucuAmathuluzi adingekayo:
Ibhodi LokuhlolaArduino Code
Arduino Code
Open the Arduino IDE and upload the following sketch to your Arduino board.
Izinto zokwakha zalesi sinyathelo:
Arduino Uno R31 ucezuAmathuluzi adingekayo:
Ikhompyutha Ene-Arduino IDETest & Experiment
Test & Experiment
What You Should See
You won't see anything — but you'll hear a melody playing from the buzzer! The song plays once and stops.
Troubleshooting
- No sound: The buzzer pins are easy to misplace on the breadboard. Double-check placement and make sure both pins have good contact.
- Want it to stop: Pull the buzzer out while working on other things, plug it back in to test.
Experiments to Try
- Remove the
while(true){}line to make the song loop continuously. - Write your own melody by changing the
notes[]andbeats[]arrays. - Add more notes by expanding the
frequency()function with sharps and flats. - Use a button (from Circuit 5) to trigger the melody on demand.
Izinto
4- SparkFun Inventor's Kit - V3.2ikhomishini engu-10%1 ikhithi$101.33
- Isibambeli
- Isibambeli
- 1 ucezuIsibambeli
Amathuluzi Adingekayo
2- Isibambeli
- 1 vendor sell this, none ship to you yetIsibambeli
CC0 Isizinda Somphakathi
Leli pulani likhishwe ngaphansi kwe-CC0. Ukhululekile ukukopisha, ukuguqula, ukusabalalisa, nokusebenzisa ngaphandle kwemvume.
Sekela uMenzi ngokuthenga imikhiqizo ngepulani labo IKhomishane Yomenzi kumiswe ngabathengisi, noma dala inguqulo entsha yaleli pulani bese uyifaka njengoxhumaniso epulanini lakho ukuze wabelane ngemali engenayo.