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
main.cpp@0:6d370baca3cf, 2019-02-18 (annotated)
- Committer:
- jasalex98
- Date:
- Mon Feb 18 16:26:11 2019 +0000
- Revision:
- 0:6d370baca3cf
Version 0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jasalex98 | 0:6d370baca3cf | 1 | #include "mbed.h" |
jasalex98 | 0:6d370baca3cf | 2 | float a=2.5; |
jasalex98 | 0:6d370baca3cf | 3 | float b=0.5; |
jasalex98 | 0:6d370baca3cf | 4 | float x=0.4; |
jasalex98 | 0:6d370baca3cf | 5 | float y=0.75; |
jasalex98 | 0:6d370baca3cf | 6 | float z=0.3; |
jasalex98 | 0:6d370baca3cf | 7 | |
jasalex98 | 0:6d370baca3cf | 8 | void avanza(float); |
jasalex98 | 0:6d370baca3cf | 9 | void espera(float); |
jasalex98 | 0:6d370baca3cf | 10 | void ireversa(float); |
jasalex98 | 0:6d370baca3cf | 11 | void reversa(float); |
jasalex98 | 0:6d370baca3cf | 12 | void derecha(float); |
jasalex98 | 0:6d370baca3cf | 13 | |
jasalex98 | 0:6d370baca3cf | 14 | DigitalOut pin1(p21); |
jasalex98 | 0:6d370baca3cf | 15 | DigitalOut pin2(p22); |
jasalex98 | 0:6d370baca3cf | 16 | DigitalOut pin3(p23); |
jasalex98 | 0:6d370baca3cf | 17 | DigitalOut pin4(p24); |
jasalex98 | 0:6d370baca3cf | 18 | |
jasalex98 | 0:6d370baca3cf | 19 | int main() { |
jasalex98 | 0:6d370baca3cf | 20 | while(1) { |
jasalex98 | 0:6d370baca3cf | 21 | avanza(2.5); |
jasalex98 | 0:6d370baca3cf | 22 | espera(0.5); |
jasalex98 | 0:6d370baca3cf | 23 | ireversa(0.4); |
jasalex98 | 0:6d370baca3cf | 24 | espera(0.5); |
jasalex98 | 0:6d370baca3cf | 25 | reversa(0.75); |
jasalex98 | 0:6d370baca3cf | 26 | espera(0.5); |
jasalex98 | 0:6d370baca3cf | 27 | derecha(0.3); |
jasalex98 | 0:6d370baca3cf | 28 | espera(0.5); |
jasalex98 | 0:6d370baca3cf | 29 | avanza(2.5); |
jasalex98 | 0:6d370baca3cf | 30 | while(1) { |
jasalex98 | 0:6d370baca3cf | 31 | pin1 = 0; |
jasalex98 | 0:6d370baca3cf | 32 | pin2 = 0; |
jasalex98 | 0:6d370baca3cf | 33 | pin3 = 0; |
jasalex98 | 0:6d370baca3cf | 34 | pin4 = 0; |
jasalex98 | 0:6d370baca3cf | 35 | } |
jasalex98 | 0:6d370baca3cf | 36 | } |
jasalex98 | 0:6d370baca3cf | 37 | } |
jasalex98 | 0:6d370baca3cf | 38 | void avanza(float a){ |
jasalex98 | 0:6d370baca3cf | 39 | pin1 = 1; |
jasalex98 | 0:6d370baca3cf | 40 | pin2 = 0; |
jasalex98 | 0:6d370baca3cf | 41 | pin3 = 1; |
jasalex98 | 0:6d370baca3cf | 42 | pin4 = 0; |
jasalex98 | 0:6d370baca3cf | 43 | wait(a); |
jasalex98 | 0:6d370baca3cf | 44 | } |
jasalex98 | 0:6d370baca3cf | 45 | void espera(float b){ |
jasalex98 | 0:6d370baca3cf | 46 | pin1 = 0; |
jasalex98 | 0:6d370baca3cf | 47 | pin2 = 0; |
jasalex98 | 0:6d370baca3cf | 48 | pin3 = 0; |
jasalex98 | 0:6d370baca3cf | 49 | pin4 = 0; |
jasalex98 | 0:6d370baca3cf | 50 | wait(b); |
jasalex98 | 0:6d370baca3cf | 51 | } |
jasalex98 | 0:6d370baca3cf | 52 | void ireversa(float x){ |
jasalex98 | 0:6d370baca3cf | 53 | pin1 = 1; |
jasalex98 | 0:6d370baca3cf | 54 | pin2 = 0; |
jasalex98 | 0:6d370baca3cf | 55 | pin3 = 0; |
jasalex98 | 0:6d370baca3cf | 56 | pin4 = 0; |
jasalex98 | 0:6d370baca3cf | 57 | wait(x); |
jasalex98 | 0:6d370baca3cf | 58 | } |
jasalex98 | 0:6d370baca3cf | 59 | void reversa(float y){ |
jasalex98 | 0:6d370baca3cf | 60 | pin1 = 0; |
jasalex98 | 0:6d370baca3cf | 61 | pin2 = 1; |
jasalex98 | 0:6d370baca3cf | 62 | pin3 = 0; |
jasalex98 | 0:6d370baca3cf | 63 | pin4 = 1; |
jasalex98 | 0:6d370baca3cf | 64 | wait(y); |
jasalex98 | 0:6d370baca3cf | 65 | } |
jasalex98 | 0:6d370baca3cf | 66 | void derecha(float z){ |
jasalex98 | 0:6d370baca3cf | 67 | pin1 = 0; |
jasalex98 | 0:6d370baca3cf | 68 | pin2 = 0; |
jasalex98 | 0:6d370baca3cf | 69 | pin3 = 1; |
jasalex98 | 0:6d370baca3cf | 70 | pin4 = 0; |
jasalex98 | 0:6d370baca3cf | 71 | wait(z); |
jasalex98 | 0:6d370baca3cf | 72 | } |