TomYumBoys / Mbed 2 deprecated MM2017

Dependencies:   mbed

Revision:
2:619b02232144
Parent:
0:cb667de3a336
Child:
3:4230b82fde43
--- a/main.cpp	Sat May 06 19:53:57 2017 +0000
+++ b/main.cpp	Sat May 13 06:13:23 2017 +0000
@@ -1,50 +1,53 @@
 #include "mbed.h"
 #include "drivecontrol.h"
 #include "pin_assignment.h"
-
 AnalogIn battery(PA_3);
 Serial pc(PA_9, PA_10);
 
+DigitalOut testLed(PB_12);
+DigitalOut testLed2(PB_13);
+DigitalOut testLed3(PB_14);
+DigitalOut testLed4(PB_15);
+
+Serial serial (PA_9, PA_10);
+
 // Define states for debugging the mouse hardware
-const int DRIVE = 1, TURN = 2, DEBUG = 3, STOP = 4;
+// const int DRIVE = 1, TURN = 2, DEBUG = 3, STOP = 4;
 // Direction of which to turn
-const int LEFT = 0, RIGHT = 1;
+// const int LEFT = 0, RIGHT = 1;
 // Start and End Pos
 const int START_POS = 0, END_POS = 0;
+
 // Terminating condition for the main control loop
 bool hasFoundCenter = false;
 
 // Battery Consumption Indicator
 void setup() {
     pc.baud(9600);
-    if (battery.read() < 0.73f){
+    if (battery.read() < 0.67f){
         // flash led
+        testLed = 1;
+        testLed2 = 1;
+        testLed3 = 1;
+        testLed4 = 1;
     }  
 }
 
 // Performs the basic drive control of the mouse
 int main() {
     DriveControl * driver = new DriveControl(START_POS, END_POS);
-    int state = DRIVE;
-    while(!hasFoundCenter) {
-        state = driver->get_next_state(state);
-        switch (state) {
-            case DRIVE:
-                driver->drive_one_forward();
-            case TURN:
-                if (driver->get_next_direction() == LEFT) {
-                    driver->turn_left();
-                }
-                else if (driver->get_next_direction() == RIGHT) {
-                    driver->turn_right();    
-                }
-            case STOP:
-                driver->stop();
-            case DEBUG:
-                // TODO
-            default:
-                // Error Condition. Flash all lights.
-                break;  
-        }
+    while(1) {
+        setup();
+
+        serial.printf("voltage value is: %3.3f%%\r\n", battery.read()*100.0f);
+        serial.printf("normalized: 0x%04X \r\n", battery.read_u16());
+        
+        testLed2 = 1;
+        testLed4 = 1;
+
+        driver->drive_one_forward();
+        wait(0.7);
+        driver->stop();
+        wait(3);
     }
-}
+}
\ No newline at end of file