-
-
Save ShravanJ/ce48864ab3360a68552d8c696edf1a30 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
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