/buzzer.ino Secret
Last active
February 21, 2018 00:56
Star
You must be signed in to star a gist
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
int buzzerPin = 28; | |
long input = 0; | |
void setup() | |
{ | |
pinMode(buzzerPin, OUTPUT) | |
Serial.begin(115200); | |
} | |
void loop() | |
{ | |
if(Serial.available() > 0) | |
{ | |
input = Serial.Read(); | |
if(input > 0) | |
{ | |
buzz(input); | |
} | |
} | |
} | |
void buzz(long duration) | |
{ | |
for(long x = 0; x < duration; x++) | |
{ | |
digitalWrite(buzzerPin, HIGH); | |
delayMicroseconds(1000); | |
digitalWrite(buzzerPin, LOW); | |
delayMicroseconds(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment