Hernán Maya
/
L298
Ejemplo de funcionamiento de una tarjeta mbed con un puente H L298
main.cpp@0:f3cd2e9ab89b, 2016-06-20 (annotated)
- Committer:
- satelite
- Date:
- Mon Jun 20 05:18:43 2016 +0000
- Revision:
- 0:f3cd2e9ab89b
Ejemplo L298
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
satelite | 0:f3cd2e9ab89b | 1 | #include "mbed.h" |
satelite | 0:f3cd2e9ab89b | 2 | |
satelite | 0:f3cd2e9ab89b | 3 | DigitalOut in1(PTC3); |
satelite | 0:f3cd2e9ab89b | 4 | DigitalOut in2(PTC2); |
satelite | 0:f3cd2e9ab89b | 5 | PwmOut ena(PTA2); |
satelite | 0:f3cd2e9ab89b | 6 | |
satelite | 0:f3cd2e9ab89b | 7 | int main() |
satelite | 0:f3cd2e9ab89b | 8 | { |
satelite | 0:f3cd2e9ab89b | 9 | while (true) { |
satelite | 0:f3cd2e9ab89b | 10 | // Detiene el motor |
satelite | 0:f3cd2e9ab89b | 11 | in1 = 0; |
satelite | 0:f3cd2e9ab89b | 12 | in2 = 0; |
satelite | 0:f3cd2e9ab89b | 13 | wait(0.5f); |
satelite | 0:f3cd2e9ab89b | 14 | // Gira en sentido 1 con velocidad 50% |
satelite | 0:f3cd2e9ab89b | 15 | in1 = 1; |
satelite | 0:f3cd2e9ab89b | 16 | in2 = 0; |
satelite | 0:f3cd2e9ab89b | 17 | ena.write(0.50f); |
satelite | 0:f3cd2e9ab89b | 18 | wait(0.5f); |
satelite | 0:f3cd2e9ab89b | 19 | // Gira en sentido 2 con velocidad 100% |
satelite | 0:f3cd2e9ab89b | 20 | in1 = 0; |
satelite | 0:f3cd2e9ab89b | 21 | in2 = 1; |
satelite | 0:f3cd2e9ab89b | 22 | ena.write(1.00f); |
satelite | 0:f3cd2e9ab89b | 23 | wait(0.5f); |
satelite | 0:f3cd2e9ab89b | 24 | } |
satelite | 0:f3cd2e9ab89b | 25 | } |