Skip to content

Instantly share code, notes, and snippets.

@yminsky
Created April 19, 2015 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yminsky/544fc49c6d9a932ba424 to your computer and use it in GitHub Desktop.
Save yminsky/544fc49c6d9a932ba424 to your computer and use it in GitHub Desktop.
The code that sounds good.
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin,LOW);
delayMicroseconds(tone);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment