Skip to content

Instantly share code, notes, and snippets.

@yminsky
Created April 19, 2015 22:49
Show Gist options
  • Save yminsky/f98996143e4631eb739b to your computer and use it in GitHub Desktop.
Save yminsky/f98996143e4631eb739b to your computer and use it in GitHub Desktop.
This one sounds worse, but is non-blocking
void play_note(long tone, long start, long now) {
long gap = now - start;
long step = gap / tone;
boolean high = (step % 2 == 0);
if (high) { digitalWrite(speaker_pin, HIGH); }
else { digitalWrite(speaker_pin,LOW); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment