With Arduino you can do a lot of interactive work, the most commonly used is for sound and light shows. LED lights are used in this experiments, we let the experiment circuit sound. Component is the buzzer and speaker, and comparison of the two buzzer easier and ease the present study, we buzzer.
Here the "source" does not mean power. But rather refers to the shock source. In other words, the active internal buzzer with shock source, so only Will be called to an energized. The passive internal sources without shocks, so if a DC signal can not make it tweet. Must 2K ~ 5K square ave to Drive it. Buzzer often than passive expensive, because there multiple oscillator circuit. Passive buzzer advantages are:
advantages are: process control, Convenient.
//Example Code for KY-006
int buzzer = 8 ;// setting controls the digital IO foot buzzer
void setup ()
{
pinMode (buzzer, OUTPUT) ;// set the digital IO pin mode, OUTPUT out of Wen
}
void loop ()
{
unsigned char i, j ;// define variables
while (1)
{
for (i = 0; i <80; i++) // Wen a frequency sound
{
digitalWrite (buzzer, HIGH) ;// send voice
delay (1) ;// Delay 1ms
digitalWrite (buzzer, LOW) ;// do not send voice
delay (1) ;// delay ms
}
for (i = 0; i <100; i++) // Wen Qie out another frequency sound
{
digitalWrite (buzzer, HIGH) ;// send voice
delay (2) ;// delay 2ms
digitalWrite (buzzer, LOW) ;// do not send voice
delay (2) ;// delay 2ms
}
}
}