6
void
pinInit
()
{
pinMode
(
SPEAKER
,
OUTPUT
);
digitalWrite
(
SPEAKER
,
LOW
);
}
void
sound
(
uint8_t note_index
)
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
digitalWrite
(
SPEAKER
,
HIGH
);
delayMicroseconds
(
BassTab
[
note_index
]);
digitalWrite
(
SPEAKER
,
LOW
);
delayMicroseconds
(
BassTab
[
note_index
]);
}
}
Note: Due to the influence of the capacitance, the module can only output the bass signal, and the treble
is unable to emit.