Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

Arduino Nano KY-006 Buzzer: Play Melodies with tone() | ShillehTek

May 14, 2026 8 views

Arduino Nano KY-006 Buzzer: Play Melodies with tone() | ShillehTek
Project

Build an Arduino Nano project that drives a KY-006 passive buzzer to play real melodies with tone(), using simple wiring and note arrays from ShillehTek.

15 min Beginner3 parts

Project Overview

Arduino Nano + KY-006 passive piezo buzzer: In this project, you will use an Arduino (such as the Arduino Nano) to drive a KY-006 passive piezo buzzer and play real melodies using tone(), not just a single fixed beep.

Unlike an active buzzer (which has one fixed tone), a passive piezo lets you drive any audio frequency from a digital pin. That means real melodies, alarm tones, and game-style sound effects, not just a one-note beep.

  • Time: ~15 minutes
  • Skill level: Beginner
  • What you will build: An Arduino playing a short melody on the KY-006 buzzer.
KY-006 passive piezo buzzer module installed on a breadboard
The KY-006 module - piezo disc + 3 pins, ready to be driven by any GPIO.

Parts List

From ShillehTek

External

  • USB cable + Arduino IDE

Note: The KY-006 has 3 pins labelled S (signal), middle (VCC), and − (GND). Driving the signal pin HIGH alone won’t make sound - you need to toggle it at audio frequency using tone().

Step-by-Step Guide

Step 1 - Active vs Passive Buzzers

Goal: Know what you have.

An active buzzer has built-in oscillator electronics; apply DC and it beeps at one fixed pitch. A passive piezo (KY-006) is just the speaker element - it needs an AC signal from your code. The trade is more wiring effort for far more flexibility.

KY-006 passive piezo buzzer module top view showing the piezo disc
The piezo disc on top - visible through the holes in the housing.

Step 2 - Wire It Up

Goal: Connect the KY-006 to the Arduino digital output and ground.

What to do: Wire the module so the Arduino can toggle the signal pin.

KY-006 passive buzzer wired to an Arduino with signal connected to D8 and ground connected to GND
Signal to D8, minus to GND. (The middle pin is unused on most KY-006 variants.)
  • S (signal) → D8 (or any digital pin)
  • − → GND

Expected result: The KY-006 is connected and ready for the tone() tests.

Step 3 - A Single Tone

Goal: Make sure the buzzer works.

What to do: Upload a simple sketch that plays one note at 440 Hz for one second.

Code:

const int BUZZER = 8;

void setup() {
  tone(BUZZER, 440, 1000);   // 440 Hz (A4) for 1 second
}

void loop() {}

Expected result: After upload, you should hear one second of a clean A note.

Step 4 - A Real Melody

Goal: Play a song instead of one note.

What to do: Use two arrays (frequencies and durations) and loop through them to play multiple notes with short gaps.

Arduino IDE showing a KY-006 tone() melody sketch with note and duration arrays
Two arrays - one for pitches, one for durations - and a loop.

Code:

const int BUZZER = 8;

// Notes (Hz) and durations (ms) for the opening of "Twinkle Twinkle"
const int notes[]    = {262, 262, 392, 392, 440, 440, 392};
const int durations[] = {400, 400, 400, 400, 400, 400, 800};

void setup() {
  for (int i = 0; i < 7; i++) {
    tone(BUZZER, notes[i], durations[i]);
    delay(durations[i] + 50);   // gap between notes
    noTone(BUZZER);
  }
}

void loop() {}
Reference table showing musical note frequencies in Hz for Arduino tone()
Note-frequency reference - C4 = 262 Hz, A4 = 440 Hz, C5 = 523 Hz, etc.

Expected result: The Arduino plays a short recognizable melody through the KY-006.

Step 5 - Hear It Play

Goal: Confirm the full melody plays correctly on your wired hardware.

What to do: Power the Arduino over USB and listen while the melody runs.

Arduino driving a KY-006 passive buzzer on a breadboard while playing a melody
The piezo is loud enough for a workbench; not loud enough for an alarm.

Expected result: You hear the melody once after reset or power-up.

Step 6 - Where to Take It Next

Goal: Ideas for extending the same KY-006 + tone() approach.

What to do: Pick a direction and swap in different note sequences or triggers.

  • Play the Mario theme, Tetris, or Imperial March (sheet music is everywhere online)
  • Trigger an alarm tone when a PIR sensor (HC-SR501) detects motion
  • Combine with the KY-037 sound sensor for a clap-and-respond circuit
  • Make button-feedback beeps for menu navigation on an OLED

Expected result: You have a clear next step for adding sound feedback to a larger Arduino project.

Conclusion

You built an Arduino Nano project that drives a KY-006 passive piezo buzzer with tone(), starting from a single 440 Hz note and moving up to a short melody using note and duration arrays.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.

Attribution: Photos and example sketches were adapted from a reference guide on Instructables.