Last active
July 21, 2016 21:30
-
-
Save GreenMoonArt/062c0bcd37d706329bac855f667295fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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