Introduction: Arduino Uno Tutorial #2 - the Buzzer Song

Hello everyone, as I saw that my first tutorial had been a good gamble, I decided that I'm gonna do a series of Arduino Uno tutorials for you!

Step 1: What You Need

For the buzzer song, you will gonna need :

-Arduino Uno Board ;

-A Buzzer (I don't have a breadboard, so I improvised with jumper wires)
-Usb cable;

-Arduino IDE in your computer;

Step 2: Conect the Board and the Buzzer

Now conect your board in the computer and conect the buzzer like the scheme on the pictures.

If you don´t have a resistor you can conect the buzzer without it, but be cautious with the polarity of the buzzer, so you don't burn it.

Step 3: Upload the Program and Finished!

The last step is too upload the program below to your Arduino IDE and to your board.

#define BUZZER 9
int notes[] = { 524, 588, 660, 699, 785, 881, 989 };

void setup()

{

pinMode(BUZZER, OUTPUT);

}

void loop()

{

for (int i = 0; i < 7; i++)

{

tone(BUZZER, notes[i], 1000); delay(1000);

}

delay(1000);

}

And you're done.

Enjoy!

Step 4: Don't Forget to Follow!

Follow for more Arduino madness!

Comments

author
millerman4487 (author)2016-05-15

here's a helpful tip: use HTML such as <pre></pre> for posting code to your instructables. Here's an example of where I used it:

https://www.instructables.com/id/Arduino-LED-Temper...

(look at the code section)

author
noel.kuck (author)2016-05-15

It is always important and useful to add plentiful comments to your code to make it easy to understand, especially since you are attempting to provide a tutorial. Nice work.

author
CarlosOliveira (author)noel.kuck2016-05-15

Thank you for the help, i'm gonna had the comments.

About This Instructable

2,276views

58favorites

License:

More by CarlosOliveira:Arduino Uno Tutorial #2 - The Buzzer SongArduino Uno Tutorial #1 - Basic blink program
Add instructable to: