Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
Multiple tones from a piezo speaker
circuit:
put a small piezo speaker on digital pin 8
and then ground it
(need not be a PWM pine)
no resistor needed
modified by Ringotron5000
*/
int speakerPin = 8;
void setup() {
}
void loop() {
tone(speakerPin, 440, 200); //play tone on pin 8 of 440 Hz for 200 ms
delay(200);
tone(speakerPin, 240, 200); //play tone on pin 8 of 240 Hz for 200 ms
delay(200);
tone(speakerPin, 120, 200);
delay(200);
tone(speakerPin, 880, 200);
delay(200);
noTone(speakerPin); // turn off tone function for pin 8:
delay(3000); // give your ears a break for 3 seconds
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.