a demo to control the movement of motor, MotorDriver library and softPWM library are both in need.

Dependencies:   MotorDriver SoftwarePWM mbed

Fork of Seeed_Motor_Shield_HelloWorld by wei zou

Revision:
0:7f7b6c3cf00f
Child:
1:870d6a20e9d6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 12 03:10:21 2014 +0000
@@ -0,0 +1,78 @@
+/*
+  main.cpp
+  2014 Copyright (c) Seeed Technology Inc.  All right reserved.
+
+  Author:lawliet.zou@gmail.com
+  2014-02-11
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include "mbed.h"
+#include "MotorDriver.h"
+
+//#define SEEEDUINO_ARCH
+#define SEEEDUINO_ARCH_PRO
+/******Pins definitions*************/
+#if defined(SEEEDUINO_ARCH)
+#define MOTORSHIELD_IN1     P1_26
+#define MOTORSHIELD_IN2     P1_29
+#define MOTORSHIELD_IN3     P0_8
+#define MOTORSHIELD_IN4     P0_9
+#define SPEEDPIN_A          P1_27
+#define SPEEDPIN_B          P0_2
+#elif defined(SEEEDUINO_ARCH_PRO)
+#define MOTORSHIELD_IN1     P0_0
+#define MOTORSHIELD_IN2     P0_9
+#define MOTORSHIELD_IN3     P0_8
+#define MOTORSHIELD_IN4     P0_7
+#define SPEEDPIN_A          P0_1
+#define SPEEDPIN_B          P0_6
+#else
+#define MOTORSHIELD_IN1     8
+#define MOTORSHIELD_IN2     11
+#define MOTORSHIELD_IN3     12
+#define MOTORSHIELD_IN4     13
+#define SPEEDPIN_A          9
+#define SPEEDPIN_B          10
+#endif
+
+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(5);
+        motorDriver.stop();
+        wait(5);
+        motorDriver.goBackward();
+        wait(5);
+        motorDriver.stop();
+        wait(5);
+        motorDriver.goLeft();
+        wait(5);
+        motorDriver.stop();
+        wait(5);
+        motorDriver.goRight();
+        wait(5);
+        motorDriver.stop();
+        wait(5);  
+    }   
+}
\ No newline at end of file