Skip to content

Instantly share code, notes, and snippets.

@buildcircuit
Created August 17, 2015 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buildcircuit/e3625a0d6d3ef713b8be to your computer and use it in GitHub Desktop.
Save buildcircuit/e3625a0d6d3ef713b8be to your computer and use it in GitHub Desktop.
Active buzzer test
int buzzer=8;// Set the control the buzzer digital IO pin
void setup()
{
pinMode(buzzer,OUTPUT);// Setting the digital IO pin mode , OUTPUT is Wen out
}
void loop()
{
unsigned char i,j;// Define the variable
while(1)
{
for(i=0;i<80;i++)// Wen a frequency sound
{
digitalWrite(buzzer,HIGH);// Sound
delay(1);//delay 1ms
digitalWrite(buzzer,LOW);//Not sound
delay(1);// delay 1ms
}
for(i=0;i<100;i++)// Wen out another frequency sound
{
digitalWrite(buzzer,HIGH);// Sound
delay(2);//delay 2ms
digitalWrite(buzzer,LOW);// Not sound
delay(2);//delay 2ms
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment