A simple Simon Says game using a Grove Base Shield, 3 Grove LED Bars, 1 Grove Buzzer, and 3 Grove Buttons.
Components Used
Platform: ST-Nucleo-F401RE
Component Configuration
LED_Bar mid(D6, D5); //D5 LED_Bar right(D8, D7); //D7 LED_Bar left(D4, D3); //D3 InterruptIn button_left(A2); InterruptIn button_mid(A1); InterruptIn button_right(A0); DigitalOut buzzer(D2);
Gallery
Diff: main.cpp
- Revision:
- 9:ac887bf9f85d
- Parent:
- 8:7be76afe5597
- Child:
- 10:9d48af13dbd0
diff -r 7be76afe5597 -r ac887bf9f85d main.cpp --- a/main.cpp Fri Aug 19 14:36:31 2016 +0000 +++ b/main.cpp Fri Aug 19 15:24:12 2016 +0000 @@ -17,11 +17,13 @@ right.setLevel(10); mid.setLevel(10); left.setLevel(10); - wait(0.2); + buzzer = 1; + wait(0.4 - i*0.1); right.setLevel(0); mid.setLevel(0); left.setLevel(0); - wait(0.2); + buzzer = 0; + wait(0.4 - i*0.1); } start_flag = true; } @@ -37,7 +39,7 @@ button_mid.rise(&start_level); button_left.rise(&start_level); while(!start_flag) { - wait(0.2); + wait(0.1); } return level_index++; } @@ -50,18 +52,16 @@ right.setLevel(10); wait(0.4); right.setLevel(0); - wait(0.4); } else if (sequence[i] == 2) { mid.setLevel(10); wait(0.4); mid.setLevel(0); - wait(0.4); } else { left.setLevel(10); wait(0.4); left.setLevel(0); - wait(0.4); } + wait(0.4); } }