Skip to content

Instantly share code, notes, and snippets.

@GreenMoonArt
Last active July 21, 2016 21:30
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 GreenMoonArt/062c0bcd37d706329bac855f667295fc to your computer and use it in GitHub Desktop.
Save GreenMoonArt/062c0bcd37d706329bac855f667295fc to your computer and use it in GitHub Desktop.
// Hook up a buzzer and use it to indicate when your robot is backing up
// source: http://forum.arduino.cc/index.php?topic=3757.0
#define BZZR 4 //digital pin to hook buzzer's red wire to
void setup() {
pinMode(BZZR, OUTPUT); //set the buzzer as output
}
void loop() {
beep();
}
void beep(){
for (int i=0; i<500; i++) { // generate a 1KHz tone for 1/2 second
digitalWrite(BZZR, HIGH);
delayMicroseconds(500);
digitalWrite(BZZR, LOW);
delayMicroseconds(500);
}
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment