5
4.
Usage
The speaker can emit a variety of sounds like a car horn, doorbell and ignition. The different sounds are
based on the frequency of the input signal.
You can supply different frequency signal to this module with Arduino. Arduino generates these signal via
PWM or even digital write and delay. Here we are going to show you how to generate these signals using
delay (), the speaker sound bass 1~7.
/*macro definition of Speaker pin*/
#define SPEAKER 3
int
BassTab
[]={
1911
,
1702
,
1516
,
1431
,
1275
,
1136
,
1012
};
//bass 1~7
void
setup
()
{
pinInit
();
}
void
loop
()
{
/*sound bass 1~7*/
for
(
int
note_index
=
0
;
note_index
<
7
;
note_index
++)
{
sound
(
note_index
);
delay
(
500
);
}
}