Example program for the SeeedStudio Motor Shield V2.0 to control the movement of 2 motors. MotorDriver library and SoftwarePWM libraries are required.

Dependencies:   MotorDriver SoftwarePWM mbed

Files at this revision

API Documentation at this revision

Comitter:
screamer
Date:
Fri May 30 13:43:04 2014 +0000
Child:
1:f017c188d2e2
Commit message:
Initial revision

Changed in this revision

MotorDriver.lib Show annotated file Show diff for this revision Revisions of this file
SoftwarePWM.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MotorDriver.lib	Fri May 30 13:43:04 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/lawliet/code/MotorDriver/#9c93f514f369
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SoftwarePWM.lib	Fri May 30 13:43:04 2014 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/takashikojo/code/SoftwarePWM/#1e86036581bd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 30 13:43:04 2014 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "MotorDriver.h"
+
+#define MOTORSHIELD_IN1     D8
+#define MOTORSHIELD_IN2     D11
+#define MOTORSHIELD_IN3     D12
+#define MOTORSHIELD_IN4     D13
+#define SPEEDPIN_A          D9
+#define SPEEDPIN_B          D10
+
+MotorDriver motorDriver(MOTORSHIELD_IN1,MOTORSHIELD_IN2,MOTORSHIELD_IN3,MOTORSHIELD_IN4,SPEEDPIN_A,SPEEDPIN_B);
+
+int main(){
+    /*Configure the motor A to control the wheel at the left side.*/
+    /*Configure the motor B to control the wheel at the right side.*/
+    motorDriver.init();
+    motorDriver.setSpeed(90,MOTORB);
+    motorDriver.setSpeed(90,MOTORA);
+    while(1){
+        motorDriver.goForward();
+        wait(2);
+        motorDriver.goBackward();
+        wait(2);
+        motorDriver.goLeft();
+        wait(2);
+        motorDriver.goRight();
+        wait(2);
+    }   
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 30 13:43:04 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file