Meike Froklage / Mbed 2 deprecated MotorA_B_Group_24

Dependencies:   Motordriver QEI mbed

Files at this revision

API Documentation at this revision

Comitter:
meikefrok
Date:
Mon Oct 03 13:47:29 2016 +0000
Commit message:
Motor A and B

Changed in this revision

Motordriver.lib Show annotated file Show diff for this revision Revisions of this file
QEI.lib Show annotated file Show diff for this revision Revisions of this file
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
diff -r 000000000000 -r 442257145c29 Motordriver.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motordriver.lib	Mon Oct 03 13:47:29 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/littlexc/code/Motordriver/#3110b9209d3c
diff -r 000000000000 -r 442257145c29 QEI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Mon Oct 03 13:47:29 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/aberk/code/QEI/#5c2ad81551aa
diff -r 000000000000 -r 442257145c29 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 03 13:47:29 2016 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+#include "motordriver.h"
+
+//LED
+//*Note: false = on, true = off*
+DigitalOut ledB(LED_BLUE);
+DigitalOut ledR(LED_RED);
+DigitalOut ledG(LED_GREEN);
+
+
+//Safety for Motor
+int Brakeable; //cna the motor driver break
+int sign; //prevents throwing the motor from full foward to full reverse and stuff melting.
+
+//Motor
+Motor A(D6, D7, D7, Brakeable); // pwm, fwd, rev, brake
+Motor B(D5, D4, D4, Brakeable); // pwm, fwd, rev, brake
+
+
+//Button
+InterruptIn btn(SW2);
+InterruptIn btn2(SW3);
+
+
+int main() {
+
+  while(true) {
+           
+        if(btn && btn2) {                   //If SW2 and SW3 aren't pressed
+            A.speed(0) == 0;               //If speed is 0, the motor doensn't rotate.
+            B.speed(0) == 0;             
+            ledR = false;                   
+            ledG = true;                    
+            ledB = true;                    
+        } else if (btn && !btn2) {          //If SW3 is pressed
+            A.speed(0.1) == 0.1;           //If the speed is positive, the motor rotates left/right. The maximum speed is 1.
+            B.speed(0.1) == 0.1;
+            ledR = true;
+            ledG = false;
+            ledB = true;            
+        } else if (!btn && btn2) {          //If SW2 is pressed
+            A.speed(-0.1) == -0.1;          //If the speed is negative, the motor rotates left/right. The maximum speed is -1.
+            B.speed(-0.1) == -0.1;
+            ledR = true;
+            ledG = true;
+            ledB = false;            
+        } else {                            //If SW2 and SW3 are pressed
+            A.speed(0) == 0;               //If speed is 0, the motor doensn't rotate.
+            B.speed(0) == 0;
+            ledR = true;
+            ledG = true;
+            ledB = true;
+        }
+
+      }
+    }
+    
+
diff -r 000000000000 -r 442257145c29 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Oct 03 13:47:29 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file