Bukit Mertajam, Penang

PROJECT 11 – PIEZO BUZZER: MELODY

PROJECT 11

PIEZO BUZZER: MELODY

Back to Project 10                                                                                                     Go to Project 12

For this project, we are going to interfacing the piezo buzzer to Arduino Duemilanove and create a simple birthday melody by just applying the Pulse Width Modulation(PWM) signal to it.

———————————————————————————————————————————————————-

COMPONENT NEEDED

———————————————————————————————————————————————————-

PIEZO BUZZER

———————————————————————————————————————————————————-

CONNECTION

———————————————————————————————————————————————————-

Referring to the figure above. The BLACK colour wire are connected to ground(GND) while the RED wire are connected to digital pin-9 as the signal tone.

———————————————————————————————————————————————————-

ADDITIONAL INFORMATION

————————————————————————————————————————————————————————-

———————————————————————————————————————————————————-

CODE OVERVIEW

———————————————————————————————————————————————————-

Define the pitches value using for typical note.

int melody[ ]
Preset the melody for birthday song.

int noteDuration[ ]
Preset the delay value for each melody note playing.

int noteDuration = 1000/noteDuration[thisnote];
To calculate the note duration, take the 1 second and divided with the note type.
E.g: 1000/3 = 333

tone (9, melody[thisnote], noteDuration);
Tone(pin, frequency, duration).
Generates a square wave of the specified frequency (and 50% duty cycle) on a pin-9.

int pauseBetweenNotes = noteDuration + 50;
Delay between the notes by adding 50ms to the noteDuration.

noTone(9);
Stops the generation of a square wave triggered by tone(). Has no effect if no tone is being generated.

Back to Project 10                                                                                                    Go to Project 12

———————————————————————————————————————————————————-

ATTACHMENT

1. P11 User Manual.pdf
2. Project_11_code.zip

Buy

[vc_cta h2=”” style=”outline” color=”white” add_button=”left” btn_title=”Buzzer 6-12V c/w Wire” btn_color=”orange” btn_i_icon_fontawesome=”fa fa-opencart” btn_css_animation=”appear” css_animation=”appear” btn_link=”url:http%3A%2F%2Fwww.cytron.com.my%2Fp-so-buzz||” btn_add_icon=”true”][/vc_cta]
[vc_cta h2=”” style=”outline” color=”white” add_button=”left” btn_title=”Arduino Uno Rev3-Main Board” btn_color=”orange” btn_i_icon_fontawesome=”fa fa-opencart” btn_css_animation=”appear” css_animation=”appear” btn_link=”url:http%3A%2F%2FArduino%20Uno%20Rev3-Main%20Board||” btn_add_icon=”true”][/vc_cta]

Related Posts

Comments (1)

I’m now not sure the place you’re getting your information,
but great topic. I needs to spend some time studying more
or working out more. Thanks for great information I used to be on the lookout for this
info for my mission.

Leave a comment

Get 7 Tips for Developing Electronic Projects
We respect your privacy.
Loading...