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
Diff: main.cpp
- Revision:
- 0:070093b01182
- Child:
- 2:9d1ef3713f82
--- /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