![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Control de estacionamiento por medio de funciones.
Dependencies: mbed
Fork of asd by
1 microcontrolador Mbed LPC1768, cortex-M3, 96MHz, 512KB Flash, 32KB RAM 1 driver puente h L298N 2 motorreductores con ruedas jumpers 1 rueda loca
Diff: main.cpp
- Revision:
- 0:6d370baca3cf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 18 16:26:11 2019 +0000 @@ -0,0 +1,72 @@ +#include "mbed.h" +float a=2.5; +float b=0.5; +float x=0.4; +float y=0.75; +float z=0.3; + +void avanza(float); +void espera(float); +void ireversa(float); +void reversa(float); +void derecha(float); + +DigitalOut pin1(p21); +DigitalOut pin2(p22); +DigitalOut pin3(p23); +DigitalOut pin4(p24); + +int main() { + while(1) { + avanza(2.5); + espera(0.5); + ireversa(0.4); + espera(0.5); + reversa(0.75); + espera(0.5); + derecha(0.3); + espera(0.5); + avanza(2.5); + while(1) { + pin1 = 0; + pin2 = 0; + pin3 = 0; + pin4 = 0; + } + } + } + void avanza(float a){ + pin1 = 1; + pin2 = 0; + pin3 = 1; + pin4 = 0; + wait(a); + } + void espera(float b){ + pin1 = 0; + pin2 = 0; + pin3 = 0; + pin4 = 0; + wait(b); + } + void ireversa(float x){ + pin1 = 1; + pin2 = 0; + pin3 = 0; + pin4 = 0; + wait(x); + } + void reversa(float y){ + pin1 = 0; + pin2 = 1; + pin3 = 0; + pin4 = 1; + wait(y); + } + void derecha(float z){ + pin1 = 0; + pin2 = 0; + pin3 = 1; + pin4 = 0; + wait(z); + } \ No newline at end of file