Arduino - Button Buzzer Melody

Introduction: Arduino - Button Buzzer Melody

About: Arduino, Raspberry Pi, esp8266, Tutorials, Projects

Play a Melody using the tone() function.

With this tutorial, we will be able to hear the melody when the button is pressed.

Step 1: Hardware Required

  • Arduino Board
  • Buzzer
  • Button
  • 10k resistor
  • Wires
  • Breadboard

Step 2: Connections

  • The button attach to the board
  • The 10k resistor connect to the button's leg
  • Resistor empty leg connect to ground
  • The button's other leg connect to +5V
  • The button's top leg connect to digital 12
  • The buzzer attach to the board
  • The buzzer's short leg (-) connect to ground
  • The buzzer's long leg (+) connect to digital 8

Step 3: Code

  • Get the Code :

  • First, include the pitches.h library.

Step 4: If It Helps, Please Subscribe

First of all, I would like to thank you for reading this guide ! I hope it helps you.

If you want to support me, you can subscribe my channel and watch my videos.

Visit My Youtube Channel - Mert Arduino Tutorial & Projects

2 People Made This Project!


  • Pocket-Sized Speed Challenge

    Pocket-Sized Speed Challenge
  • Audio Challenge 2020

    Audio Challenge 2020
  • Maps Challenge

    Maps Challenge



2 years ago

Hey, I tried the code you gave for simple buzzer function. I want it to do the following, once the button is pressed, the tones go from 1000 to 2000 in increments of 100 and delay of 300.

There is a small problem I am facing. I have to keep the button pressed to allow the buzzer to work. it stops as soon as I release the button.

Please help.

Thanks :)