single player mbedKart

Dependencies:   Motor

(notes)

Revision:
6:57a0323bb6b7
Parent:
5:839f7f3e31d6
Child:
7:ee46a1d4227b
--- a/main.cpp	Sun Dec 09 22:14:14 2018 +0000
+++ b/main.cpp	Mon Dec 10 01:39:15 2018 +0000
@@ -18,7 +18,7 @@
 int max_speed;
 int acceleration;
 int cstate;
-bool colide = false;
+bool collide = false;
 
 // Global game actions
 bool game_paused = false;
@@ -33,19 +33,13 @@
     // Read data from color sensor (Clear/Red/Green/Blue)
     while (true) { 
         myRGBled.write(1.0,0.0,0.0); //red
-        wait(2.0);
+        Thread::wait(2000);
         myRGBled.write(0.0,1.0,0.0); //green
-        wait(2.0);
+        Thread::wait(2000);
         myRGBled.write(0.0,0.0,1.0); //blue
-        wait(2.0);
+        Thread::wait(2000);
         myRGBled.write(1.0,0.2,0.0); //yellow = red + some green
-        wait(2.0);
-        //white with a slow fade to black dimming effect
-        for (float x=1.0; x>=0.0001; x=x*0.99) {
-            myRGBled.write(x, x, x);
-            Thread::wait(500);
-        }
-        Thread::wait(100);
+        Thread::wait(2000);
     }
 }    
 
@@ -67,7 +61,7 @@
         cstate = 0;
     }
     else if(C_value > thresh && R_value > thresh && G_value > thresh && B_value > thresh) {     //Check if cart collides with wall
-        colide = true;
+        collide = true;
     }
     else if(C_value > thresh && R_value > thresh && G_value > thresh && B_value > thresh) {     //Check if cart reaches next checkpoint. cstate is set to 1 upon seeing first color of checkpoint
         cstate = 1;
@@ -83,11 +77,13 @@
 }
 
 // Define threads
-Thread thread1(item_thread);
+Thread thread1;
+Thread thread2;
 
 int main() {
     // Start threads
     thread1.start(item_thread);
+    thread2.start(check_RGB);
     
     // Bluetooth controller code
     char bnum=0;