Skip to content

Instantly share code, notes, and snippets.

@bboyho
Created October 16, 2018 17:26
Show Gist options
  • Save bboyho/e7eddf00f819e804552f0776ac09c548 to your computer and use it in GitHub Desktop.
Save bboyho/e7eddf00f819e804552f0776ac09c548 to your computer and use it in GitHub Desktop.
#include "pitches.h" // must include open source pitches.h found online in libraries folder or make a new tab => https://www.arduino.cc/en/Tutorial/toneMelody
int button1State = LOW;
void setup() {
pinMode(4, INPUT_PULLUP);
pinMode(5, OUTPUT);
}
void loop() {
button1State = digitalRead(4);
if (button1State == LOW) {
// Play coin sound
digitalWrite(5, HIGH); // turn the LED on
tone(10, NOTE_B5, 100);
delay(100);
tone(10, NOTE_E6, 850);
delay(800);
noTone(10);
digitalWrite(5, LOW); // turn the LED on
}
else {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment