Fa2018-es200-1121-project2-herndon-toss / Mbed OS herndon-threaded

Dependencies:   Servo Motor

Revision:
5:226dfa7d6308
Parent:
4:5ba96337741c
Child:
6:f76e93f043e2
--- a/main.cpp	Mon Oct 22 13:24:22 2018 +0000
+++ b/main.cpp	Tue Oct 23 01:00:41 2018 +0000
@@ -28,6 +28,8 @@
 DigitalOut firing_led(LED3); // indicates firing
 DigitalOut recycle_led(LED4); // indicates recycling 
 
+DigitalOut LEDs[5]={p25, p26, p27, p28, p29}; // possible LEDs that can be lit
+
 
 // Herndon wiggling thread stuff
 Thread herndon_thread;  // thread to run Herndon in
@@ -80,6 +82,7 @@
         pc.printf("main() entering aiming mode, turn dial to aim cover\r\n"); 
         aiming_led.write(1); 
         while(!launch_sw3.read()){
+            LEDs[0] = 1;
             pc.printf("main() aiming, dial at %f, servo at %f\r\n",traverse_pot.read(),traverse_servo.read()); 
             traverse_servo.write(traverse_pot.read());
             ThisThread::sleep_for(200); 
@@ -88,6 +91,7 @@
         
         // firing state
         firing_led.write(1); 
+        LEDs[1] = 1;
         pc.printf("main() thread entering cover launch sequence\r\n"); 
         pc.printf("main() thread motor launch cover\r\n");
         launch_motor.speed(1.0);
@@ -97,11 +101,13 @@
         pc.printf("main() thread awaiting order to recycle\r\n"); 
         firing_led.write(0); 
         while(!recycle_sw4.read()){
+        
             ThisThread::sleep_for(200);
             } // wait for user to
         
         // recovery state
         recycle_led.write(1); 
+        LEDs[3] = 1;
         pc.printf("main() thread recycling catapult back to battery\r\n"); 
         pc.printf("main() thread motor reversing back to battery \r\n");
         launch_motor.speed(-0.25);
@@ -113,8 +119,12 @@
         recycle_led.write(0); 
         
         }// while(1)
-    
-    
+    LEDs[0] = 0;
+    LEDs[1] = 0;
+    LEDs[2] = 0;
+    LEDs[3] = 0;
+    LEDs[4] = 0;
+
 } // main()
 
 
@@ -146,7 +156,7 @@
                 xinc = -0.1; // switch to moving left
                 pc.printf("herndon_thread hit right end, now moving left\r\n");
             } // hit the right end
-            
+            LEDs[4] = 1;
             else if (x < 0.0) {
                 x = 0.0;
                 xinc = 0.1; // switch to moving right
@@ -179,6 +189,7 @@
     
     // heartbeat_thread loop here
     while(1) {
+        LEDs[2] = 1;
         heartbeat_led = !heartbeat_led;
         ThisThread::sleep_for(500);
     } // while(1)