![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
asdf
Diff: main.cpp
- Revision:
- 0:c4ec289ae3a7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 20 17:30:30 2013 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +DigitalOut EN(p25); +PwmOut IN1(p21); +PwmOut IN2(p22); +PwmOut IN3(p23); +PwmOut IN4(p24); + +//from -1 to 1 +void motorpower(float left, float right){ + IN1 = right < 0 ? -right : 0; + IN2 = right >= 0 ? right : 0; + IN3 = left >= 0 ? left : 0; + IN4 = left < 0 ? -left : 0; +} + +int main() { + + motorpower(0, 0); + EN = 1; + + while(1) { + wait(1); + motorpower(0.2, 0.2); + wait(1); + motorpower(-0.2, 0.2); + wait(1); + motorpower(0,0); + } +}