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
main.cpp
- Committer:
- screamer
- Date:
- 2014-05-30
- Revision:
- 0:070093b01182
- Child:
- 2:9d1ef3713f82
File content as of revision 0:070093b01182:
#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); } }