Many modern megaphones have settings that use a loud
amplified buzzer. They are usually very loud and quite
good at getting people’s attention.
Circuit 2
Arduino Code:
11
Troubleshooting:
No Sound
Given the size and shape of the piezo buzzer it is easy to
miss the right holes on the breadboard. Try double
checking its placement.
Can't Think While the Melody is Playing
Just pull up the piezo buzzer whilst you think, upload
your program then plug it back in.
Feeling Let Down and Deserted
The code is written so you can easily add your own songs.
You should see - well, nothing!
But you should be able to hear a
song. If it isn't working, make
sure you have assembled the
circuit correctly and verified and
uploaded the code to your board
or see the troubleshooting tips
below.
Code to Note:
Real World Application:
Open Arduino IDE
//
File > Examples > SIK Guide >
Circuit # 11
What You Should See:
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
LEARN. SHARE. HACK.
Up until now we've been working solely with numerical data, but
the Arduino can also work with text. Characters (single, printable,
letters, numbers and other symbols) have their own type, called
"char". When you have an array of characters, it can be defined
between double-quotes (also called a "string"), OR as a list of
single-quoted characters.
char notes[] = "cdfda ag cdfdg gf ";
char names[] = {'c','d','e','f','g','a','b','C'};
One of Arduino's many useful built-in commands is the tone()
function. This function drives an output pin at a certain
frequency, making it perfect for driving buzzers and speakers. If
you give it a duration (in milliseconds), it will play the tone then
stop. If you don't give it a duration, it will keep playing the tone
forever (but you can stop it with another function, noTone() ).
tone(pin, frequency, duration);
Page 64
Содержание RedBoard
Страница 13: ...Page 11...