Nurbol Nurdaulet / Mbed 2 deprecated state_machine

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Nurbol
Date:
Thu Nov 24 10:18:57 2011 +0000
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 24 10:18:57 2011 +0000
@@ -0,0 +1,70 @@
+#include "mbed.h"
+
+static int state(0);
+
+int main() {
+    while(1) {
+    switch(state)
+    {
+        case 0:
+             servo_4.pulsewidth_us(1000 + (25 * 1000) / 90);
+             servo_0.pulsewidth_us(1000 + (0 * 1000) / 90); 
+             servo_5.pulsewidth_us(1000 + (0 * 1000) / 90); 
+             Position1p_1 = 1;
+             Position1p_2 = 0;
+             Position2p_1 = 1;
+             Position2p_2 = 0;
+             if(counter1p == 1){
+                state = 1;
+             }
+             if(counter2p == 1){
+                state = 4;
+             }
+             break;
+        case 1:
+             servo_4.pulsewidth_us(0);
+             servo_0.pulsewidth_us(1000 + (200 * 1000) / 90); 
+             wait(1);
+             Position1p_1 = 0;
+             Position1p_2 = 1;
+             if(Position1p_2 == 1){
+                state = 2;
+             }
+             break;
+        case 2:
+             servo_4.pulsewidth_us(1000 + (25 * 1000) / 90);
+             if(counter1p = 1){
+                state = 3;
+             }
+             break;
+        case 3:
+             servo_4.pulsewidth_us(0);
+             if(SW1p == 1){
+                state = 0;
+             }
+             break;
+        case 4:
+             servo_4.pulsewidth_us(0);
+             servo_5.pulsewidth_us(1000 + (200 * 1000) / 90);
+             wait(1);
+             Position2p_1 = 0;
+             Position2p_2 = 1;
+             if(Position2p_2 == 1){
+                state = 5;
+             }
+             break;
+        case 5:
+             servo_4.pulsewidth_us(1000 + (25 * 1000) / 90);
+             if(counter2p == 1){
+                state = 6;
+             }
+             break;
+        case 6:
+             servo_4.pulsewidth_us(0);
+             if(SW2p == 1){
+                state = 0;
+             }
+             break;         
+    }   
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 24 10:18:57 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912