Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FastPWM mbed QEI biquadFilter HIDScope MODSERIAL
Diff: main.cpp
- Revision:
- 6:3c9569087274
- Parent:
- 5:047db32db712
- Child:
- 7:7c005b3cf288
- Child:
- 9:65c52c1f4a57
diff -r 047db32db712 -r 3c9569087274 main.cpp --- a/main.cpp Tue Sep 25 15:39:40 2018 +0000 +++ b/main.cpp Mon Oct 08 08:16:05 2018 +0000 @@ -4,28 +4,41 @@ Ticker motor; -FastPWM pin5(D5); + AnalogIn pot1(A1); AnalogIn pot2(A2); -DigitalOut pin4(D4); -//float u = pot1; +FastPWM pin5(D5); // Motor 2 pwm +DigitalOut pin4(D4); // Motor 2 direction +FastPWM pin6(D6); // Motor 1 pwm +DigitalOut pin7(D7); // Motor 1 direction +//float u1 = pot1; void draai(){ - float u = 2.0*(pot1 - 0.5); - - if (u>0){ - pin4 = true; - } - else if(u<0){ - pin4 = false; - } - - pin5 = fabs(u); + float u1 = 2.0*(pot1 - 0.5); + if (u1>0) + { pin4 = true; + } + else if(u1<0) + { pin4 = false; + } + pin5 = fabs(u1); + + float u2 = 2.0*(pot2 - 0.5); + if (u2>0) + { pin7 = true; + } + else if(u2<0) + { pin7 = false; + } + pin6 = fabs(u2); } int main(){ - pin5.period_us(50); - motor.attach(draai, 0.001); + pin5.period_us(50); + motor.attach(draai, 0.001); + + pin6.period_us(50); + motor.attach(draai, 0.001); while(true){ }