Control de motor DC con PWM y lectura de encoder

Dependencies:   mbed

Revision:
1:6c77f3712d4f
Parent:
0:b0ff1d4513c5
--- 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;