this is

Dependencies:   mbed Servo Motor

Revision:
3:a7c54d27d7f7
Parent:
2:260539a94ad7
Child:
4:6888480c5133
--- a/main.cpp	Tue Oct 16 15:43:05 2018 +0000
+++ b/main.cpp	Tue Oct 16 17:44:02 2018 +0000
@@ -19,6 +19,7 @@
 int n; // preventatibe variable
 int o; // preventative variable
 int w = 0; //counter for successful attempts
+float timer;
 
 int main() {
     
@@ -30,6 +31,7 @@
     scanf("%10d\n\r",&s);
     srand(s);
     k=0;
+    timer = .02;
     wait(3);
     
     for (i=0; i<10; i++){ //for
@@ -45,7 +47,7 @@
             leds[r] = 0;
             k=1; // ensure fail code isn't activated
             }//turn off again and loop
-            wait(0.02);//have 0.5 seconds to respond
+            wait(timer);//have 0.5 seconds to respond
              
         if (button[r] == 1) {//if good response
             printf("noice\n\r");//good
@@ -55,7 +57,7 @@
             leds[r] = 0;
             l=1;
             }//turn off again and loop
-            wait(0.02);//have 0.5 seconds to respond
+            wait(timer);//have 0.5 seconds to respond
              
         if (button[r] == 1) {//if good response
             printf("noice\n\r");//good
@@ -65,7 +67,7 @@
             leds[r] = 0;
             m=1;
             }//turn off again and loop
-            wait(0.02);//have 0.5 seconds to respond
+            wait(timer);//have 0.5 seconds to respond
              
         if (button[r] == 1) {//if good response
             printf("noice\n\r");//good
@@ -75,7 +77,7 @@
             leds[r] = 0;
             n=1;
             }//turn off again and loop
-            wait(0.02);//have 0.5 seconds to respond
+            wait(timer);//have 0.5 seconds to respond
              
         if (button[r] == 1) {//if good response
             printf("noice\n\r");//good
@@ -97,8 +99,10 @@
         ledz[1]=0;
         }//if
         
-        if (k==1 || l==1 || m==1 || n==1 ||o==1) {w = w + 1;
+        if (k==1 || l==1 || m==1 || n==1 ||o==1) { // if
+            w = w + 1;
         }//end if
+        
         leds[r]=0;
         k=0;
         l=0;