Double-clap light switch
Clap twice and the lights come on. Clap twice again to switch them off.
Shop by category
Shop all componentsEvery musical note is a frequency: middle C is 262 Hz, A is 440 Hz. The Arduino tone() function makes a square wave at any frequency on a pin, and a passive buzzer turns it into sound. A list of notes and a list of lengths are played one by one, then the tune pauses for 3 seconds and repeats. This needs the passive buzzer from the kit: an active buzzer only knows one tone.
Every part for this build comes in the Geekobot Spark Kit box, a Geekobot exclusive, together with the parts for all 24 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
The brain of every Spark Kit project
Female-to-female or male-to-female leads for the modules
Sensor Shield v5.0 from the kit: every pin has its own G, V, S header, so modules plug in with female jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
spark_kit_08_musical_buzzer.inoVerify & upload in Electrolark// Spark Kit 08: musical buzzer (passive buzzer on D11)
int buzzer = 11;
// "Twinkle twinkle" opening: C C G G A A G
int melody[] = {262, 262, 392, 392, 440, 440, 392};
int duration[] = {400, 400, 400, 400, 400, 400, 800};
void setup() {}
void loop() {
for (int i = 0; i < 7; i++) {
tone(buzzer, melody[i], duration[i]);
delay(duration[i] * 1.3); // short gap between notes
}
noTone(buzzer);
delay(3000);
}
Use the kit's USB cable (some phone cables carry power only), install the CH340 driver on Windows if the port does not appear, and pick Tools > Board > Arduino Uno.
You are using the active buzzer. Swap in the passive buzzer module.
Check the arrays have the same number of items and that the for loop counts to that number.
tone() changes the pitch, and only a passive buzzer follows it. An active buzzer plays its own fixed tone whatever you send.
Yes. Look up note frequencies (C4 262, D4 294, E4 330, F4 349, G4 392, A4 440, B4 494, C5 523) and fill the two arrays.
Yes. It is one of the 24 projects in the Geekobot Spark Kit, and every part on the list comes in the kit box. You can also buy the parts one by one from the list above.
No. Every Spark Kit project is wired on the breadboard or the Sensor Shield with jumper wires.
5 parts: Uno R3 CH340G ATmega328p Compatible Development Board, Arduino USB-A to USB-B Data Cable for UNO/MEGA, Buzzer Module 3.3–5V, Dupont Jumper Wires (40 pcs) and Arduino Sensor Shield V5 Expansion Board. On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 30 minutes. The build on this page has 4 steps.
No. This page has the complete, tested code (spark_kit_08_musical_buzzer.ino).
About ₹412 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
tone() and noTone(); Musical note frequencies; Arrays of notes and durations.
Clap twice and the lights come on. Clap twice again to switch them off.
Plays a friendly ding-dong whenever someone walks into the shop or room.
Beeps and flashes any message in Morse, or key your own by hand.
Turn a membrane keypad into a two-octave piano.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.