Engine control program with 3 engines Needs to make a case for each simultaneous engine setting, because of the WAIT after each number of bits have been sent.

Dependencies:   mbed-rtos mbed PinDetect

Fork of FinalMotorControl by Robot Bachelor

Revision:
1:a3287196a9b3
Parent:
0:bd78e433db61
Child:
2:25bcc26f7a5b
--- a/main.cpp	Mon Feb 29 12:10:54 2016 +0000
+++ b/main.cpp	Thu Apr 07 10:51:36 2016 +0000
@@ -1,14 +1,18 @@
 #include "mbed.h"
+#include "rtos.h"
 
 
+//Analog Pins
 DigitalOut IN1(D3);
 DigitalOut IN2(D4);
-
 DigitalOut IN3(D5);
 DigitalOut IN4(D6);
 
+Mutex stdio_mutex;
+static int fart = 1000;
+static char global_direction;
+static int global_counter;
 
-DigitalIn  SW(USER_BUTTON);
 
 void step4Right()
 {
@@ -16,60 +20,83 @@
     IN2=1;
     IN3=0;
     IN4=1;
-    wait_us(1000);
+    wait_us(fart); //legg som global variabel "fart" 
     IN1=0;
     IN2=1;
     IN3=1;
     IN4=0;
-    wait_us(1000);
+    wait_us(fart);
     IN1=1;
     IN2=0;
     IN3=1;
     IN4=0;
-    wait_us(1000);
+    wait_us(fart);
     IN1=1;
     IN2=0;
     IN3=0;
     IN4=1;
-    wait_us(1000);
+    wait_us(fart);
 }
-
-
 void step4Left()
 {
     IN1=1;
     IN2=0;
     IN3=0;
     IN4=1;
-    wait_us(1000);
+    wait_us(fart);
 
     IN1=1;
     IN2=0;
     IN3=1;
     IN4=0;
-    wait_us(1000);
+    wait_us(fart);
 
     IN1=0;
     IN2=1;
     IN3=1;
     IN4=0;
-    wait_us(1000);
+    wait_us(fart);
 
     IN1=0;
     IN2=1;
     IN3=0;
     IN4=1;
-    wait_us(1000);
+    wait_us(fart);
 }
 
+  
+void input(void const *args)
+{
+    while(true)
+    {
+        scanf(" %c", &global_direction);
+    }
+}
 
 int main()
 {
-    while (true) {
-        if(SW==1)
+        //Thread 1 has constant feed from usb
+        //Thread t1(input);
+        while (true) 
+        {
             step4Left();
-        else
-            step4Right();
 
-    }
-}
\ No newline at end of file
+    /*
+            if (global_direction == '0')
+            {
+                step4Left();
+                printf("%c \n" + global_direction); 
+            } */
+            /*else if (global_direction == '1')
+            {
+                step4Right();
+                //printf("RIGHT \n"); 
+            } */
+           /* else
+            {
+                //Do nothing
+                
+            }*/
+        }  
+            
+} //END Main
\ No newline at end of file