javier vicente
/
MASTER_DC_MOTOR_PWM
Control de motor DC con PWM y lectura de encoder
Revision 1:6c77f3712d4f, committed 2020-12-11
- Comitter:
- javiervicente
- Date:
- Fri Dec 11 12:13:24 2020 +0000
- Parent:
- 0:b0ff1d4513c5
- Commit message:
- bueno
Changed in this revision
diff -r b0ff1d4513c5 -r 6c77f3712d4f main.cpp --- a/main.cpp Tue Dec 01 07:58:37 2020 +0000 +++ b/main.cpp Fri Dec 11 12:13:24 2020 +0000 @@ -2,10 +2,9 @@ Serial pc(USBTX, USBRX); // tx, rx -DigitalOut enableMotor(D8); -DigitalOut dirAMotor(D9); -PwmOut dirBMotor(D10); -InterruptIn encoderA(D11); +DigitalOut dirAMotor(A4); +PwmOut dirBMotor(A3); +InterruptIn encoderA(A2); int contador=0; @@ -18,12 +17,11 @@ { pc.baud(115200); encoderA.rise(&encoderAIrq); // attach the address of the flip function to the rising edge - enableMotor=1; dirAMotor=0; while (true) { for (float i=0; i<1; i=i+0.01) { dirBMotor=i; - thread_sleep_for(100); + wait(0.100); } pc.printf("Vueltas: %d\r\n",contador); contador=0;
diff -r b0ff1d4513c5 -r 6c77f3712d4f mbed-os.lib --- a/mbed-os.lib Tue Dec 01 07:58:37 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9
diff -r b0ff1d4513c5 -r 6c77f3712d4f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Dec 11 12:13:24 2020 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/0f02307a0877 \ No newline at end of file