Sample Source code how to use a buzzer connected to Arduino,
Electronic Parts you need
1x Arduino Uno / Mega / Pro
1x Buzzer or Beeper
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
int buzzer=7; void setup() { pinMode(buzzer,OUTPUT); } void loop() { unsigned char i,j; while(1) { for(i=0;i<80;i++) { digitalWrite(buzzer,HIGH); delay(1); digitalWrite(buzzer,LOW); delay(1); } for(i=0;i<100;i++) { digitalWrite(buzzer,HIGH); delay(2); digitalWrite(buzzer,LOW); delay(2); } } } |
Download the core here | 14CoreBuzzer
Starter #6 Using Buzzer in Arduino Sample Code