PWM with L298

Dependencies:   mbed TextLCD1

Fork of L298 by Hernán Maya

main.cpp

Committer:
juanitoinig84
Date:
2016-06-23
Revision:
2:2e93c305bb62
Parent:
1:c83539e7f8a0

File content as of revision 2:2e93c305bb62:

#include "mbed.h"


Serial pc(USBTX,USBRX);            // tx,rx
DigitalOut in1(PTC3);
DigitalOut in2(PTC2);
PwmOut     ena(PTA2);

DigitalOut in3(PTD1);
DigitalOut in4(PTD2);
PwmOut     enb(PTD3);

void rxInterrupt(){
}
int main()

{
pc.baud(115200);
pc.attach(&rxInterrupt);
    while (true) {
    /////******MOTOR 1****////
        // Detiene el motor
        in1 = 0; 
        in2 = 0;
        wait(0.5f);
        // Gira en sentido 1 con velocidad 50%
        in1 = 1;
        in2 = 0;
        ena.write(0.50f);
        wait(0.5f);
        // Gira en sentido 2 con velocidad 100%
        in1 = 0;
        in2 = 1;
        ena.write(1.00f);
        wait(0.5f);
        
    /////******MOTOR 2****////
      /* in3 = 0; 
        in4 = 0;
        wait(0.5f);
        // Gira en sentido 1 con velocidad 50%
        in3 = 1;
        in4 = 0;
        ena.write(0.50f);
        wait(0.5f);
        // Gira en sentido 2 con velocidad 100%
        in3 = 0;
        in4 = 1;
        ena.write(1.00f);
        wait(0.5f);*/
        pc.printf("MOTOR Funcionando\n");
        
    }
}