mobile robot control with artificial hormones

Dependencies:   Communication_Robot RTC-DS1307 iSerial mbed

Fork of Andante_v00 by potiwat ngamkajornwiwat

Revision:
8:af8fbf678f28
Parent:
5:aae71a94cb41
diff -r b504c8b9fbd8 -r af8fbf678f28 main.cpp
--- a/main.cpp	Wed Dec 23 11:28:52 2015 +0000
+++ b/main.cpp	Tue Dec 06 12:17:09 2016 +0000
@@ -49,6 +49,9 @@
 
 int main()
 {
+    Timer t;
+    uint8_t action_state=1;
+    uint8_t first_time=0;
     myled=0;
 
 
@@ -67,11 +70,36 @@
 
 
     pan_a.sendCommunicatePacket(&packet);
+
+    t.start();
     while(1) {
 
         //   uint8_t status = pan_a.receiveCommunicatePacket(&packet);
 
         // pan_a.sendCommunicatePacket(&packet);
+        switch(action_state) {
+            case 1:// forward max speec
+                if(first_time == 0) {
+
+                    setFrontAngle(0.0);
+                    setRearAngle(0.0);
+                    setSpeedControl(1.0);
+                    t.reset();
+                    first_time=1;
+                } else if(t.read() >= 1.0) {
+                    setFrontAngle(0.0);
+                    setRearAngle(0.0);
+                    setSpeedControl(0.0);
+
+                    action_state =2;
+                    first_time = 0;
+                }
+                break;
+            case 2://backward max speed
+            break;
+        }
+
+
     }
 }
 
@@ -84,7 +112,7 @@
 
     uint8_t status = pan_a.receiveCommunicatePacket(&packet);
     myled=0;
-    
+
 
 
     if(status == ANDANTE_ERRBIT_NONE) {
@@ -92,7 +120,7 @@
             count--;
         } else {
             count=0;
-            
+
         }
         pan_a.sendCommunicatePacket(&packet);
         //update command