int buzzer = 9;
void setup() {
// put your setup code here, to run once:
pinMode(buzzer, OUTPUT);
}
void buzzerPin() {
unsigned char i;
while (1)
{
//output an frequency
for (i = 0; i < 80; i++)
{
digitalWrite(buzzer, HIGH);
delay(1);//wait for 1ms
digitalWrite(buzzer, LOW);
delay(1);//wait for 1ms
}
//output another frequency
for (i = 0; i < 100; i++)
{
digitalWrite(buzzer, HIGH);
delay(2);//wait for 2ms
digitalWrite(buzzer, LOW);
delay(2);//wait for 2ms
}
}
}
void loop() {
// put your main code here, to run repeatedly:
buzzerPin();
}