Skip to content

Instantly share code, notes, and snippets.

@ShravanJ
Last active February 21, 2018 00:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ShravanJ/ce48864ab3360a68552d8c696edf1a30 to your computer and use it in GitHub Desktop.
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