1 sola salida de PWM del KL25Z para el Enable del puente H. 1 solo botón conectado a un NOT. La negación va al IN1 y la no negada va al IN2. Para que con un solo botón haya un control del giro del motor pero sin freno.

Dependencies:   mbed

motordc3.cpp

Committer:
alonsoangulo
Date:
2015-12-01
Revision:
0:657fc6ce0791

File content as of revision 0:657fc6ce0791:

#include "mbed.h"
AnalogIn pot(PTB3);
PwmOut motordc(PTD4);
DigitalIn boton(PTB2);
DigitalOut IN1(PTD0);
DigitalOut IN2(PTD5);
DigitalOut myled(LED1);

int main() {
    
    myled=0;
    wait(0.5);
    myled=1;

        
    while(1) {
        
        
        if(boton==1){
            float input = pot; 
            motordc = input; 
            IN1=1;
            IN2=0;
            wait(0.1);
        } else if(boton==0){
            float input = pot; 
            motordc = input; 
            IN1=0;
            IN2=1;
            wait(0.1);
                
                }
    }
}