mirror of https://github.com/nealey/Simon-Says
Commented Combo Code
This commit is contained in:
parent
d6fffc3e57
commit
4c56765330
|
@ -1,9 +1,11 @@
|
||||||
/*
|
/*
|
||||||
Code to
|
Code checks for combination in order. Must press upper left button, then upper right button,
|
||||||
|
then lower left for success. Any wrong button will result in an unplesant sound,
|
||||||
|
and the code will reset.
|
||||||
|
|
||||||
Prof Mike Soltys
|
Prof Mike Soltys
|
||||||
University of Colorado
|
University of Colorado
|
||||||
1/28/2014
|
1/31/2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,13 +65,22 @@ void loop() {
|
||||||
if (Button == UR){
|
if (Button == UR){
|
||||||
// if so, turn that button on and continue
|
// if so, turn that button on and continue
|
||||||
digitalWrite(led_UR, HIGH);
|
digitalWrite(led_UR, HIGH);
|
||||||
// play success tone!
|
Button = ButtonWait();
|
||||||
tone(BUZZER1,399,1000);
|
if (Button == LL){
|
||||||
// interesting fact: 399 Hz is the "most plesant" frequency
|
// if so, turn that button on and continue
|
||||||
// http://www.ncbi.nlm.nih.gov/pubmed/503755
|
digitalWrite(led_LL, HIGH);
|
||||||
|
// play success tone!
|
||||||
|
tone(BUZZER1,399,1000);
|
||||||
|
// interesting fact: 399 Hz is the "most plesant" frequency
|
||||||
|
// http://www.ncbi.nlm.nih.gov/pubmed/503755
|
||||||
|
|
||||||
// if at any point a wrong button is pressed, the code will jump down
|
// if at any point a wrong button is pressed, the code will jump down
|
||||||
// to delay 1000, turn off the LEDs, and restart at the top of void loop()
|
// to delay 1000, turn off the LEDs, and restart at the top of void loop()
|
||||||
|
}
|
||||||
|
// if the wrong button is pressed, play an unplesant sound
|
||||||
|
else {
|
||||||
|
tone(BUZZER1,2000,500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// if the wrong button is pressed, play an unplesant sound
|
// if the wrong button is pressed, play an unplesant sound
|
||||||
else {
|
else {
|
||||||
|
@ -80,7 +91,7 @@ void loop() {
|
||||||
else {
|
else {
|
||||||
tone(BUZZER1,2000,500);
|
tone(BUZZER1,2000,500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait a second and turn off all LEDS
|
// wait a second and turn off all LEDS
|
||||||
delay(1000);
|
delay(1000);
|
||||||
digitalWrite(led_UR, LOW);
|
digitalWrite(led_UR, LOW);
|
||||||
|
@ -132,3 +143,4 @@ int ButtonWait(void){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue