Commented Combo Code

This commit is contained in:
Mike S 2014-01-31 11:03:56 -07:00
parent d6fffc3e57
commit 4c56765330
1 changed files with 21 additions and 9 deletions

View File

@ -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
University of Colorado
1/28/2014
1/31/2014
*/
@ -63,6 +65,10 @@ void loop() {
if (Button == UR){
// if so, turn that button on and continue
digitalWrite(led_UR, HIGH);
Button = ButtonWait();
if (Button == LL){
// if so, turn that button on and continue
digitalWrite(led_LL, HIGH);
// play success tone!
tone(BUZZER1,399,1000);
// interesting fact: 399 Hz is the "most plesant" frequency
@ -80,6 +86,11 @@ void loop() {
else {
tone(BUZZER1,2000,500);
}
}
// if the wrong button is pressed, play an unplesant sound
else {
tone(BUZZER1,2000,500);
}
// wait a second and turn off all LEDS
delay(1000);
@ -132,3 +143,4 @@ int ButtonWait(void){