Tutorial 6: Using Buzzer to Play a Melody
English Chinese (Simplified) Czech French German Hindi Italian Japanese Korean Russian Spanish

In this tutorial we will show you how use the UNO R3 PLUS to drive a buzzer.  We will show you how to build a buzzer circuit and how to play a scale.  We will also show you how to play a short melody with an example sketch.

 

I – Stuffs that you will need:

You will need a UNO R3 Plus board, a mini USB to standard USB cable, a PC as well as a breadboard, buzzer, resistors, jumper cables and a NPN transistor for assembling the buzzer circuit.

 


UNO R3 Plus

Mini USB to Standard USB

Windows PC

Breadboard

Buzzer (TDK PS1420P02CT)

2x 1kohm Resistor

Jumper cables 

2N3904 NPN transistor
 

                          

II – Background Information:

The buzzer we are using in this tutorial is a TDK PS1420P02CT.  This buzzer has the following specifications and characteristics:

When applying a rectangular wave to the buzzer, a tone will get generated.  The higher the frequency of the rectangular wave, the higher frequency the buzzer will produce.

 

 

III – Schematic Diagram:

Below is the schematic diagram.  We will use digital pin 8 to drive the buzzer.

 

 

IV – Wiring the Breadboard:

Let’s wire up the bread board.  Be sure to pay attention to the positive and negative terminal of the buzzer.  Also pay attention to the connection of the NPN transistor.  The pin on the left is the emitter, the center pin is the base and the pin at the right is the collector.

 

 

 

IV – Writing the Sketch:

Start a new project and copy and paste the below sketches into the Arduino environment.  These sketches use the tone function to generate the rectangular wave to the buzzer.  The first sketch will play C scale.  The second sketch will pay a melody.  You can also load this sketch from the example tab in the Arduino environment.

 

CLICK TO DOWNLOAD ALL TUTORIAL CODES:  ARD101_Tutorial_Code

 

Things we have covered in this tutorial:

  • Making sounds with a buzzer.

 

Tutorial 7: Counting Down with a 7 Segment LED

Tutorial 8: Powering the UNO R3 PLUS Using Batteries

 

Download  ARD-101 Tutorial Codes