Skip to content

Instantly share code, notes, and snippets.

@t-kashima
Created May 21, 2015 14:27
Show Gist options
  • Save t-kashima/fa85b7faf9ba7957ebb1 to your computer and use it in GitHub Desktop.
Save t-kashima/fa85b7faf9ba7957ebb1 to your computer and use it in GitHub Desktop.
Slide swith and speaker for Arduino
void setup() {
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, INPUT);
digitalWrite(12, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(13) == HIGH) {
// digitalWrite(11, HIGH);
tone(11, 262, 300);
delay(300);
tone(11, 294, 300);
delay(300);
tone(11, 330, 300);
delay(300);
} else {
noTone(11);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment