A simple Simon Says game using a Grove Base Shield, 3 Grove LED Bars, 1 Grove Buzzer, and 3 Grove Buttons.

Dependencies:   LED_Bar mbed

Components Used

Platform: ST-Nucleo-F401RE

Components / Grove Shield V2
As an expansion board, Base Shield v2 has many Grove connectors, making it convenient for you to use Grove products together
Digital on / off buzzer
Seeed Grove Button module with digital interface
The Grove LED Bar is comprised of a 10 segment LED gauge bar and an MY9221 LED controlling chip.

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

Revision:
9:ac887bf9f85d
Parent:
8:7be76afe5597
Child:
10:9d48af13dbd0
--- 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);
     }
 }