Software to run a motor driver

Dependencies:   mbed

Revision:
0:701ca418bae4
diff -r 000000000000 -r 701ca418bae4 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 15 09:04:07 2018 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+
+DigitalOut IN1(D8);
+DigitalOut IN2(D9);
+PwmOut ENA(D3);
+
+DigitalOut IN3(D6);
+DigitalOut IN4(D7);
+PwmOut ENB(D5);
+
+void Init();
+void Sortir();
+void Entrer();
+void Stop();
+
+int main() 
+{
+    Init();
+    
+    Sortir();
+    wait(2);
+    Entrer();
+    wait(2);
+    
+    ENB = 1;
+    IN3 = 0;
+    IN4 = 1;
+}
+
+void Init()
+{
+    wait_ms(500);
+    IN1 = 0;
+    IN2 = 0;
+    IN3 = 0;
+    IN4 = 0;
+}
+
+void Sortir()
+{
+    ENA = 0.2;
+    IN1 = 1;
+    IN2 = 0;
+    wait(2.5);
+    Stop();
+}
+
+void Entrer()
+{
+    ENA = 0.2;
+    IN1 = 0;
+    IN2 = 1;
+    wait(1.7);
+    Stop();
+}
+
+void Stop()
+{
+    IN1 = 0;
+    IN2 = 0;
+}
\ No newline at end of file