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:
3:96879db74ec8
Parent:
2:8ff96f7acb45
Child:
4:9950f9ec46cf
--- a/main.cpp	Wed Aug 17 15:45:49 2016 +0000
+++ b/main.cpp	Thu Aug 18 16:47:00 2016 +0000
@@ -7,10 +7,13 @@
 DigitalIn button_left(A2);
 DigitalIn button_top(A1);
 DigitalIn button_right(A0);
+DigitalOut buzzer(D2);
+Ticker input_timer;
 int input[50];
 int sequence[] = {3, 2, 1, 3, 2, 1};
+int level_index = 0;
 
-void start_up() {
+void level() {
     //generate random simon says sequence
     
     //wait for user input
@@ -45,7 +48,6 @@
 /*  gather user input based on buttons pressed, then store button # into
     the input array (1=button_right, 2=button_top, 3=button_left) */
 void input_loop() {
-
     for(int j = 0; j < (sizeof(sequence)/sizeof(sequence[0])); j++) { 
         wait(0.4);
         if (button_top) {
@@ -83,7 +85,7 @@
     return true;
 }
 
-/*  display a happy LED animation for winning (LED levels 0 to 10 fast, twice) */
+/*  display a happy LED animation for winning (LED levels 0 to 10 fast) */
 void success() {
     for(int h = 0; h <=10; h++){
         top.setLevel(h);
@@ -112,11 +114,12 @@
     }
 }
 
-int main() {
+void start_game() {
     top.setLevel(0);
     right.setLevel(0);
     left.setLevel(0);
-    start_up();
+    //next_level:
+    //level();
     wait(0.3);
     simon_loop();
     input_loop();
@@ -124,4 +127,11 @@
     bool winner = win_or_lose();
     if (winner == true) { success(); } 
     else { failure(); }
+    //if (level < 10) then { GoTo next_level; }
 }
+
+int main() {
+    start_game();
+}
+
+//buzzer_timer.attach(&timer_handler, 0.5)
\ No newline at end of file