Created
April 1, 2019 00:49
-
-
Save jazzyjackson/f715147b4004d4dd44c176d194e803d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
pinMode(9, OUTPUT); | |
pinMode(1, INPUT_PULLUP); | |
pinMode(2, INPUT_PULLUP); | |
pinMode(3, INPUT_PULLUP); | |
pinMode(4, INPUT_PULLUP); | |
pinMode(5, INPUT_PULLUP); | |
pinMode(6, INPUT_PULLUP); | |
pinMode(7, INPUT_PULLUP); | |
} | |
void loop() { | |
if(digitalRead(1) == LOW){ | |
tone(261); | |
} | |
if(digitalRead(2) == LOW){ | |
tone(293); | |
} | |
if(digitalRead(3) == LOW){ | |
tone(329); | |
} | |
if(digitalRead(4) == LOW){ | |
tone(349); | |
} | |
if(digitalRead(5) == LOW){ | |
tone(391); | |
} | |
if(digitalRead(6) == LOW){ | |
tone(450); | |
} | |
if(digitalRead(7) == LOW){ | |
tone(520); | |
} | |
} | |
void tone(float freq){ | |
digitalWrite(9, HIGH); // turn the LED on (HIGH is the voltage level) | |
delayMicroseconds(1000000 / freq / 2); // wait for a second | |
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW | |
delayMicroseconds(1000000 / freq / 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment