Skip to content

Instantly share code, notes, and snippets.

@ShravanJ
Last active Feb 21, 2018
Embed
What would you like to do?
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