PWM with L298 for two DC Motors.
Dependencies: mbed FPointer TextLCD1 keypad
Fork of L298 by
Diff: main.cpp
- Revision:
- 3:5d21835b1f70
- Parent:
- 2:2e93c305bb62
diff -r 2e93c305bb62 -r 5d21835b1f70 main.cpp --- a/main.cpp Thu Jun 23 12:43:49 2016 +0000 +++ b/main.cpp Sat Jun 25 18:33:26 2016 +0000 @@ -16,23 +16,46 @@ { pc.baud(115200); +ena.period_us(50); pc.attach(&rxInterrupt); while (true) { /////******MOTOR 1****//// // Detiene el motor in1 = 0; in2 = 0; - wait(0.5f); + wait(2.0f); + //Gira en sentido 1 con velocidad 25% + in1 = 1; + in2 = 0; + ena.write(0.25f); + wait(2.0f); // Gira en sentido 1 con velocidad 50% in1 = 1; in2 = 0; ena.write(0.50f); - wait(0.5f); + wait(2.0f); + // Gira en sentido 1 con velocidad 75% + in1 = 1; + in2 = 0; + ena.write(0.75f); + wait(2.0f); + + // Gira en sentido 1 con velocidad 100% + in1 = 1; + in2 = 0; + ena.write(1.00f); + wait(2.0f); + + // Gira en sentido 2 con velocidad 75% + /*in1 = 0; + in2 = 1; + ena.write(0.75f); + wait(2.0f); // Gira en sentido 2 con velocidad 100% - in1 = 0; + in1 = 0; in2 = 1; ena.write(1.00f); - wait(0.5f); + wait(1.0f);*/ /////******MOTOR 2****//// /* in3 = 0; @@ -41,14 +64,14 @@ // Gira en sentido 1 con velocidad 50% in3 = 1; in4 = 0; - ena.write(0.50f); + enb.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"); + enb.write(1.00f); + wait(0.5f); + pc.printf("MOTOR Funcionando\n");*/ } } \ No newline at end of file