Programa realizado para el trabajo: SISTEMA DE DETECCIÓN Y ALERTAS POR APROXIMACIÓN DE VEHÍCULOS EN ZONAS CIEGAS DE UNA MOTOCICLETA // JOSE ALBERTO RUIZ ORTEGA // UNIVERSIDAD NACIONAL DE COLOMBIA // SEDE MEDELLÍN // Realizado con colaboración del estudiante Jair Hernan Vargas y asesoría de los docentes: Gustavo Ramirez y Jesus Hernandez
Dependencies: DebouncedIn HCSR04 HCSR042 HCSR043 HCSR044 MMA8451Q TextLCD USBDevice mbed
main.cpp@0:694ea51ef4bf, 2014-12-04 (annotated)
- Committer:
- jaruiz
- Date:
- Thu Dec 04 06:32:31 2014 +0000
- Revision:
- 0:694ea51ef4bf
Programa realizado para el trabajo: SISTEMA DE DETECCI?N Y ALERTAS POR APROXIMACI?N DE VEH?CULOS EN ZONAS CIEGAS DE UNA MOTOCICLETA // JOSE ALBERTO RUIZ ORTEGA // INGENIER?A DE CONTROL// UNAL;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jaruiz | 0:694ea51ef4bf | 1 | // |
jaruiz | 0:694ea51ef4bf | 2 | // |
jaruiz | 0:694ea51ef4bf | 3 | // SISTEMA DE DETECCIÓN Y ALERTAS POR APROXIMACIÓN DE VEHÍCULOS EN |
jaruiz | 0:694ea51ef4bf | 4 | // ZONAS CIEGAS DE UNA MOTOCICLETA |
jaruiz | 0:694ea51ef4bf | 5 | // |
jaruiz | 0:694ea51ef4bf | 6 | // JOSE ALBERTO RUIZ ORTEGA |
jaruiz | 0:694ea51ef4bf | 7 | // 1085262530 |
jaruiz | 0:694ea51ef4bf | 8 | // |
jaruiz | 0:694ea51ef4bf | 9 | // INGENIERIA DE CONTROL |
jaruiz | 0:694ea51ef4bf | 10 | // |
jaruiz | 0:694ea51ef4bf | 11 | // UNIVERSIDAD NACIONAL DE COLOMBIA |
jaruiz | 0:694ea51ef4bf | 12 | // |
jaruiz | 0:694ea51ef4bf | 13 | // Programa realizado para la detección de vehiculos que se acercan a una motocicleta. |
jaruiz | 0:694ea51ef4bf | 14 | // Para la realización de este trabajo se contó con la colaboracion del estudiante Jair Hernán Vargas |
jaruiz | 0:694ea51ef4bf | 15 | // |
jaruiz | 0:694ea51ef4bf | 16 | |
jaruiz | 0:694ea51ef4bf | 17 | |
jaruiz | 0:694ea51ef4bf | 18 | //:::::::::::::::::: Librerías |
jaruiz | 0:694ea51ef4bf | 19 | #include "mbed.h" |
jaruiz | 0:694ea51ef4bf | 20 | #include "HCSR04.h" |
jaruiz | 0:694ea51ef4bf | 21 | #include "HCSR042.h" |
jaruiz | 0:694ea51ef4bf | 22 | #include "HCSR043.h" |
jaruiz | 0:694ea51ef4bf | 23 | #include "HCSR044.h" |
jaruiz | 0:694ea51ef4bf | 24 | #include "TextLCD.h" |
jaruiz | 0:694ea51ef4bf | 25 | #include "MMA8451Q.h" |
jaruiz | 0:694ea51ef4bf | 26 | #include "DebouncedIn.h" |
jaruiz | 0:694ea51ef4bf | 27 | #define MMA8451_I2C_ADDRESS (0x1d<<1) |
jaruiz | 0:694ea51ef4bf | 28 | |
jaruiz | 0:694ea51ef4bf | 29 | //:::::::::::::::::: Puertos |
jaruiz | 0:694ea51ef4bf | 30 | MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); |
jaruiz | 0:694ea51ef4bf | 31 | PwmOut rojo(LED_RED); |
jaruiz | 0:694ea51ef4bf | 32 | PwmOut verde(LED_GREEN); |
jaruiz | 0:694ea51ef4bf | 33 | PwmOut azul(LED_BLUE); |
jaruiz | 0:694ea51ef4bf | 34 | DigitalOut led2(PTE23); |
jaruiz | 0:694ea51ef4bf | 35 | DigitalOut led3(PTE29); |
jaruiz | 0:694ea51ef4bf | 36 | DigitalOut led4(PTC17); |
jaruiz | 0:694ea51ef4bf | 37 | DigitalOut led5(PTA16); |
jaruiz | 0:694ea51ef4bf | 38 | PwmOut ledD(PTC8); |
jaruiz | 0:694ea51ef4bf | 39 | PwmOut ledI(PTC9); |
jaruiz | 0:694ea51ef4bf | 40 | PwmOut sound(PTA12); |
jaruiz | 0:694ea51ef4bf | 41 | DigitalOut ledbD(PTC7); |
jaruiz | 0:694ea51ef4bf | 42 | DigitalOut ledbI(PTC0); |
jaruiz | 0:694ea51ef4bf | 43 | DigitalOut ledgD(PTC5); |
jaruiz | 0:694ea51ef4bf | 44 | DigitalOut ledgI(PTC6); |
jaruiz | 0:694ea51ef4bf | 45 | HCSR04 sensor(PTD4, PTA13); |
jaruiz | 0:694ea51ef4bf | 46 | HCSR042 sensor2(PTA5, PTD5); |
jaruiz | 0:694ea51ef4bf | 47 | HCSR043 sensor3(PTA1, PTD0); |
jaruiz | 0:694ea51ef4bf | 48 | HCSR044 sensor4(PTA4, PTD2); |
jaruiz | 0:694ea51ef4bf | 49 | DebouncedIn button1(PTC12); |
jaruiz | 0:694ea51ef4bf | 50 | |
jaruiz | 0:694ea51ef4bf | 51 | //:::::::::::::::::::::::::::::: Display |
jaruiz | 0:694ea51ef4bf | 52 | |
jaruiz | 0:694ea51ef4bf | 53 | TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); |
jaruiz | 0:694ea51ef4bf | 54 | |
jaruiz | 0:694ea51ef4bf | 55 | //:::::::::::::::::::::::::::::: Variables |
jaruiz | 0:694ea51ef4bf | 56 | |
jaruiz | 0:694ea51ef4bf | 57 | float X,Y,Z; |
jaruiz | 0:694ea51ef4bf | 58 | bool b; |
jaruiz | 0:694ea51ef4bf | 59 | bool a; |
jaruiz | 0:694ea51ef4bf | 60 | bool c; |
jaruiz | 0:694ea51ef4bf | 61 | bool d; |
jaruiz | 0:694ea51ef4bf | 62 | int e; |
jaruiz | 0:694ea51ef4bf | 63 | float DD1; |
jaruiz | 0:694ea51ef4bf | 64 | float DD2; |
jaruiz | 0:694ea51ef4bf | 65 | |
jaruiz | 0:694ea51ef4bf | 66 | //::::::::::::::::::::::::::::::::: PROGRAMA |
jaruiz | 0:694ea51ef4bf | 67 | int main() |
jaruiz | 0:694ea51ef4bf | 68 | { |
jaruiz | 0:694ea51ef4bf | 69 | |
jaruiz | 0:694ea51ef4bf | 70 | while(1){ |
jaruiz | 0:694ea51ef4bf | 71 | //a=0; |
jaruiz | 0:694ea51ef4bf | 72 | |
jaruiz | 0:694ea51ef4bf | 73 | //b=0; |
jaruiz | 0:694ea51ef4bf | 74 | //:::::::::::::::::::::::::: Acelerómetro |
jaruiz | 0:694ea51ef4bf | 75 | |
jaruiz | 0:694ea51ef4bf | 76 | |
jaruiz | 0:694ea51ef4bf | 77 | X=acc.getAccX(); |
jaruiz | 0:694ea51ef4bf | 78 | Y=acc.getAccY(); |
jaruiz | 0:694ea51ef4bf | 79 | Z=acc.getAccZ(); |
jaruiz | 0:694ea51ef4bf | 80 | rojo=1.0 - abs(X); |
jaruiz | 0:694ea51ef4bf | 81 | verde=1.0 - abs(Y); |
jaruiz | 0:694ea51ef4bf | 82 | azul=1.0 - abs(Z); |
jaruiz | 0:694ea51ef4bf | 83 | wait(0.1); |
jaruiz | 0:694ea51ef4bf | 84 | |
jaruiz | 0:694ea51ef4bf | 85 | if (Y>=0.1) |
jaruiz | 0:694ea51ef4bf | 86 | { |
jaruiz | 0:694ea51ef4bf | 87 | led2=1; |
jaruiz | 0:694ea51ef4bf | 88 | c=1; |
jaruiz | 0:694ea51ef4bf | 89 | d=0; |
jaruiz | 0:694ea51ef4bf | 90 | } |
jaruiz | 0:694ea51ef4bf | 91 | else |
jaruiz | 0:694ea51ef4bf | 92 | { |
jaruiz | 0:694ea51ef4bf | 93 | led2=0; |
jaruiz | 0:694ea51ef4bf | 94 | c=0; |
jaruiz | 0:694ea51ef4bf | 95 | } |
jaruiz | 0:694ea51ef4bf | 96 | if (Y<=-0.1) |
jaruiz | 0:694ea51ef4bf | 97 | { |
jaruiz | 0:694ea51ef4bf | 98 | d=1; |
jaruiz | 0:694ea51ef4bf | 99 | c=0; |
jaruiz | 0:694ea51ef4bf | 100 | led3=1; |
jaruiz | 0:694ea51ef4bf | 101 | } |
jaruiz | 0:694ea51ef4bf | 102 | else |
jaruiz | 0:694ea51ef4bf | 103 | { |
jaruiz | 0:694ea51ef4bf | 104 | led3=0; |
jaruiz | 0:694ea51ef4bf | 105 | d=0; |
jaruiz | 0:694ea51ef4bf | 106 | } |
jaruiz | 0:694ea51ef4bf | 107 | |
jaruiz | 0:694ea51ef4bf | 108 | // :::::::::::::::::::::::::::::::::: Selección de Modos |
jaruiz | 0:694ea51ef4bf | 109 | |
jaruiz | 0:694ea51ef4bf | 110 | lcd.locate(0,0); |
jaruiz | 0:694ea51ef4bf | 111 | lcd.printf("e:%d ",e); |
jaruiz | 0:694ea51ef4bf | 112 | wait(0.1); |
jaruiz | 0:694ea51ef4bf | 113 | |
jaruiz | 0:694ea51ef4bf | 114 | if (button1.falling()) |
jaruiz | 0:694ea51ef4bf | 115 | { |
jaruiz | 0:694ea51ef4bf | 116 | e=e+1; |
jaruiz | 0:694ea51ef4bf | 117 | |
jaruiz | 0:694ea51ef4bf | 118 | } |
jaruiz | 0:694ea51ef4bf | 119 | if (e==3) |
jaruiz | 0:694ea51ef4bf | 120 | { |
jaruiz | 0:694ea51ef4bf | 121 | e=0; |
jaruiz | 0:694ea51ef4bf | 122 | } |
jaruiz | 0:694ea51ef4bf | 123 | |
jaruiz | 0:694ea51ef4bf | 124 | // MODO CARRETERA |
jaruiz | 0:694ea51ef4bf | 125 | if (e==0) |
jaruiz | 0:694ea51ef4bf | 126 | { |
jaruiz | 0:694ea51ef4bf | 127 | DD1=120; |
jaruiz | 0:694ea51ef4bf | 128 | DD2=400; |
jaruiz | 0:694ea51ef4bf | 129 | lcd.locate(0,0); |
jaruiz | 0:694ea51ef4bf | 130 | lcd.printf("Modo Carretera"); |
jaruiz | 0:694ea51ef4bf | 131 | wait(0.1); |
jaruiz | 0:694ea51ef4bf | 132 | } |
jaruiz | 0:694ea51ef4bf | 133 | |
jaruiz | 0:694ea51ef4bf | 134 | // MODO CIUDAD |
jaruiz | 0:694ea51ef4bf | 135 | |
jaruiz | 0:694ea51ef4bf | 136 | if (e==1) |
jaruiz | 0:694ea51ef4bf | 137 | { |
jaruiz | 0:694ea51ef4bf | 138 | DD1=70; |
jaruiz | 0:694ea51ef4bf | 139 | DD2=300; |
jaruiz | 0:694ea51ef4bf | 140 | lcd.locate(0,1); |
jaruiz | 0:694ea51ef4bf | 141 | lcd.printf("Modo Ciudad"); |
jaruiz | 0:694ea51ef4bf | 142 | wait(0.1); |
jaruiz | 0:694ea51ef4bf | 143 | } |
jaruiz | 0:694ea51ef4bf | 144 | |
jaruiz | 0:694ea51ef4bf | 145 | // MODO SIN ALARMAS |
jaruiz | 0:694ea51ef4bf | 146 | |
jaruiz | 0:694ea51ef4bf | 147 | if (e==2) |
jaruiz | 0:694ea51ef4bf | 148 | { |
jaruiz | 0:694ea51ef4bf | 149 | sound=0; |
jaruiz | 0:694ea51ef4bf | 150 | lcd.locate(0,1); |
jaruiz | 0:694ea51ef4bf | 151 | lcd.printf("Modo Sin Alarma"); |
jaruiz | 0:694ea51ef4bf | 152 | wait(0.1); |
jaruiz | 0:694ea51ef4bf | 153 | } |
jaruiz | 0:694ea51ef4bf | 154 | |
jaruiz | 0:694ea51ef4bf | 155 | //:::::::::::::::::::::::::::::::::::::::::::::SENSADO |
jaruiz | 0:694ea51ef4bf | 156 | |
jaruiz | 0:694ea51ef4bf | 157 | // SENSOR 1 DERECHA ________________________________________________________________________________________ |
jaruiz | 0:694ea51ef4bf | 158 | long d = sensor.distance(1); |
jaruiz | 0:694ea51ef4bf | 159 | lcd.locate(0,0); |
jaruiz | 0:694ea51ef4bf | 160 | lcd.printf("DER:%d ",sensor.distance(1)); |
jaruiz | 0:694ea51ef4bf | 161 | |
jaruiz | 0:694ea51ef4bf | 162 | |
jaruiz | 0:694ea51ef4bf | 163 | // SENSOR 2 IZQUIERDA ________________________________________________________________________________________ |
jaruiz | 0:694ea51ef4bf | 164 | long s = sensor2.distance(1); |
jaruiz | 0:694ea51ef4bf | 165 | lcd.locate(8,0); |
jaruiz | 0:694ea51ef4bf | 166 | lcd.printf("IZQ:%d ",sensor2.distance(1)); |
jaruiz | 0:694ea51ef4bf | 167 | |
jaruiz | 0:694ea51ef4bf | 168 | // SENSOR 3 POSTERIOR ________________________________________________________________________________________ |
jaruiz | 0:694ea51ef4bf | 169 | long p = sensor3.distance(1); |
jaruiz | 0:694ea51ef4bf | 170 | lcd.locate(0,1); |
jaruiz | 0:694ea51ef4bf | 171 | lcd.printf("FRN:%d ",sensor3.distance(1)); |
jaruiz | 0:694ea51ef4bf | 172 | //wait(0.5); |
jaruiz | 0:694ea51ef4bf | 173 | |
jaruiz | 0:694ea51ef4bf | 174 | // SENSOR 4 FRONTAL ________________________________________________________________________________________ |
jaruiz | 0:694ea51ef4bf | 175 | long q = sensor4.distance(1); |
jaruiz | 0:694ea51ef4bf | 176 | lcd.locate(8,1); |
jaruiz | 0:694ea51ef4bf | 177 | lcd.printf("TRS:%d ",sensor4.distance(1)); |
jaruiz | 0:694ea51ef4bf | 178 | //wait(0.5); |
jaruiz | 0:694ea51ef4bf | 179 | |
jaruiz | 0:694ea51ef4bf | 180 | //:::::::::::::::::::::::: ALARMAS |
jaruiz | 0:694ea51ef4bf | 181 | |
jaruiz | 0:694ea51ef4bf | 182 | // ::::::::::::::::::::::::::::::::ALERTA MUY CERCANA DERECHA |
jaruiz | 0:694ea51ef4bf | 183 | |
jaruiz | 0:694ea51ef4bf | 184 | if (d>-1 && d<=DD1) |
jaruiz | 0:694ea51ef4bf | 185 | { |
jaruiz | 0:694ea51ef4bf | 186 | lcd.locate(0,0); |
jaruiz | 0:694ea51ef4bf | 187 | lcd.printf("AMAXD "); |
jaruiz | 0:694ea51ef4bf | 188 | ledbD=0; |
jaruiz | 0:694ea51ef4bf | 189 | ledgD=0; |
jaruiz | 0:694ea51ef4bf | 190 | |
jaruiz | 0:694ea51ef4bf | 191 | ledD.period(4.0); // 4 second period |
jaruiz | 0:694ea51ef4bf | 192 | //ledD.pulsewidth(0.2); // 2 second pulse (on) |
jaruiz | 0:694ea51ef4bf | 193 | ledD.write(0.20f); // 50% duty cycle |
jaruiz | 0:694ea51ef4bf | 194 | //while(1); // led flashing |
jaruiz | 0:694ea51ef4bf | 195 | a=1; |
jaruiz | 0:694ea51ef4bf | 196 | } |
jaruiz | 0:694ea51ef4bf | 197 | |
jaruiz | 0:694ea51ef4bf | 198 | // ::::::::::::::::::::::::::::::::ALERTA MUY CERCANA IZQUIERDA |
jaruiz | 0:694ea51ef4bf | 199 | if(s>-1 && s<=DD1) |
jaruiz | 0:694ea51ef4bf | 200 | { |
jaruiz | 0:694ea51ef4bf | 201 | lcd.locate(8,0); |
jaruiz | 0:694ea51ef4bf | 202 | lcd.printf("AMAXI "); |
jaruiz | 0:694ea51ef4bf | 203 | ledbI=0; |
jaruiz | 0:694ea51ef4bf | 204 | ledgI=0; |
jaruiz | 0:694ea51ef4bf | 205 | |
jaruiz | 0:694ea51ef4bf | 206 | ledI.period(6.0); // 4 second period |
jaruiz | 0:694ea51ef4bf | 207 | //ledI.pulsewidth(0.2); // 2 second pulse (on) |
jaruiz | 0:694ea51ef4bf | 208 | ledI.write(0.20f); // 50% duty cycle |
jaruiz | 0:694ea51ef4bf | 209 | //while(1); // led flashing |
jaruiz | 0:694ea51ef4bf | 210 | a=1; |
jaruiz | 0:694ea51ef4bf | 211 | } |
jaruiz | 0:694ea51ef4bf | 212 | |
jaruiz | 0:694ea51ef4bf | 213 | // ::::::::::::::::::::::::::::::::ALERTA CERCANA DERECHA |
jaruiz | 0:694ea51ef4bf | 214 | if(d>DD1 && d<=DD2) |
jaruiz | 0:694ea51ef4bf | 215 | { |
jaruiz | 0:694ea51ef4bf | 216 | ledD=0; |
jaruiz | 0:694ea51ef4bf | 217 | ledbD=1; |
jaruiz | 0:694ea51ef4bf | 218 | ledgD=0; |
jaruiz | 0:694ea51ef4bf | 219 | a=1; |
jaruiz | 0:694ea51ef4bf | 220 | lcd.locate(0,0); |
jaruiz | 0:694ea51ef4bf | 221 | lcd.printf("AMIND "); |
jaruiz | 0:694ea51ef4bf | 222 | |
jaruiz | 0:694ea51ef4bf | 223 | } |
jaruiz | 0:694ea51ef4bf | 224 | |
jaruiz | 0:694ea51ef4bf | 225 | // ::::::::::::::::::::::::::::::::ALERTA CERCANA IZQUIERDA |
jaruiz | 0:694ea51ef4bf | 226 | if(s>DD1 && s<=DD2) |
jaruiz | 0:694ea51ef4bf | 227 | { |
jaruiz | 0:694ea51ef4bf | 228 | ledI=0; |
jaruiz | 0:694ea51ef4bf | 229 | ledbI=1; |
jaruiz | 0:694ea51ef4bf | 230 | ledgI=0; |
jaruiz | 0:694ea51ef4bf | 231 | a=1; |
jaruiz | 0:694ea51ef4bf | 232 | lcd.locate(8,0); |
jaruiz | 0:694ea51ef4bf | 233 | lcd.printf("AMINI "); |
jaruiz | 0:694ea51ef4bf | 234 | } |
jaruiz | 0:694ea51ef4bf | 235 | |
jaruiz | 0:694ea51ef4bf | 236 | |
jaruiz | 0:694ea51ef4bf | 237 | // ::::::::::::::::::::::::::::::::SIN ALERTAS DERECHA |
jaruiz | 0:694ea51ef4bf | 238 | if(d>DD2) |
jaruiz | 0:694ea51ef4bf | 239 | { |
jaruiz | 0:694ea51ef4bf | 240 | ledD=0; |
jaruiz | 0:694ea51ef4bf | 241 | ledbD=0; |
jaruiz | 0:694ea51ef4bf | 242 | ledgD=1; |
jaruiz | 0:694ea51ef4bf | 243 | a=0; |
jaruiz | 0:694ea51ef4bf | 244 | lcd.locate(0,0); |
jaruiz | 0:694ea51ef4bf | 245 | lcd.printf("NOALD "); |
jaruiz | 0:694ea51ef4bf | 246 | } |
jaruiz | 0:694ea51ef4bf | 247 | |
jaruiz | 0:694ea51ef4bf | 248 | //:::::::::::::::::::::::::::::::: SIN ALERTAS IZQ |
jaruiz | 0:694ea51ef4bf | 249 | if(s>DD2) |
jaruiz | 0:694ea51ef4bf | 250 | { |
jaruiz | 0:694ea51ef4bf | 251 | ledI=0; |
jaruiz | 0:694ea51ef4bf | 252 | ledbI=0; |
jaruiz | 0:694ea51ef4bf | 253 | ledgI=1; |
jaruiz | 0:694ea51ef4bf | 254 | a=0; |
jaruiz | 0:694ea51ef4bf | 255 | lcd.locate(8,0); |
jaruiz | 0:694ea51ef4bf | 256 | lcd.printf("NOALI "); |
jaruiz | 0:694ea51ef4bf | 257 | } |
jaruiz | 0:694ea51ef4bf | 258 | // :::::::::::::::::::::::::::::::: SIN ALERTAS DERECHA |
jaruiz | 0:694ea51ef4bf | 259 | if(d==-1) |
jaruiz | 0:694ea51ef4bf | 260 | { |
jaruiz | 0:694ea51ef4bf | 261 | ledD=0; |
jaruiz | 0:694ea51ef4bf | 262 | ledbD=0; |
jaruiz | 0:694ea51ef4bf | 263 | ledgD=1; |
jaruiz | 0:694ea51ef4bf | 264 | a=0; |
jaruiz | 0:694ea51ef4bf | 265 | lcd.locate(0,0); |
jaruiz | 0:694ea51ef4bf | 266 | lcd.printf("NOALD "); |
jaruiz | 0:694ea51ef4bf | 267 | } |
jaruiz | 0:694ea51ef4bf | 268 | |
jaruiz | 0:694ea51ef4bf | 269 | // :::::::::::::::::::::::::::::::: SIN ALERTAS IZQUIERDA |
jaruiz | 0:694ea51ef4bf | 270 | if(s==-1) |
jaruiz | 0:694ea51ef4bf | 271 | { |
jaruiz | 0:694ea51ef4bf | 272 | ledI=0; |
jaruiz | 0:694ea51ef4bf | 273 | ledbI=0; |
jaruiz | 0:694ea51ef4bf | 274 | ledgI=1; |
jaruiz | 0:694ea51ef4bf | 275 | a=0; |
jaruiz | 0:694ea51ef4bf | 276 | lcd.locate(8,0); |
jaruiz | 0:694ea51ef4bf | 277 | lcd.printf("NOALI "); |
jaruiz | 0:694ea51ef4bf | 278 | } |
jaruiz | 0:694ea51ef4bf | 279 | |
jaruiz | 0:694ea51ef4bf | 280 | |
jaruiz | 0:694ea51ef4bf | 281 | // ::::::::::::::::::::::::::::::::alarma POSTERIOR |
jaruiz | 0:694ea51ef4bf | 282 | if (p<=100) |
jaruiz | 0:694ea51ef4bf | 283 | { |
jaruiz | 0:694ea51ef4bf | 284 | led4=1; |
jaruiz | 0:694ea51ef4bf | 285 | } |
jaruiz | 0:694ea51ef4bf | 286 | else |
jaruiz | 0:694ea51ef4bf | 287 | { |
jaruiz | 0:694ea51ef4bf | 288 | led4=0; |
jaruiz | 0:694ea51ef4bf | 289 | } |
jaruiz | 0:694ea51ef4bf | 290 | |
jaruiz | 0:694ea51ef4bf | 291 | // ::::::::::::::::::::::::::::::::alarma POSTERIOR |
jaruiz | 0:694ea51ef4bf | 292 | if (q<=100) |
jaruiz | 0:694ea51ef4bf | 293 | { |
jaruiz | 0:694ea51ef4bf | 294 | led5=1; |
jaruiz | 0:694ea51ef4bf | 295 | } |
jaruiz | 0:694ea51ef4bf | 296 | else |
jaruiz | 0:694ea51ef4bf | 297 | { |
jaruiz | 0:694ea51ef4bf | 298 | led5=0; |
jaruiz | 0:694ea51ef4bf | 299 | } |
jaruiz | 0:694ea51ef4bf | 300 | // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::SONIDO |
jaruiz | 0:694ea51ef4bf | 301 | |
jaruiz | 0:694ea51ef4bf | 302 | if (abs(Y)>=0.1 && a==1) |
jaruiz | 0:694ea51ef4bf | 303 | { |
jaruiz | 0:694ea51ef4bf | 304 | sound=1; |
jaruiz | 0:694ea51ef4bf | 305 | wait(0.07); |
jaruiz | 0:694ea51ef4bf | 306 | sound=0; |
jaruiz | 0:694ea51ef4bf | 307 | } |
jaruiz | 0:694ea51ef4bf | 308 | |
jaruiz | 0:694ea51ef4bf | 309 | |
jaruiz | 0:694ea51ef4bf | 310 | |
jaruiz | 0:694ea51ef4bf | 311 | } |
jaruiz | 0:694ea51ef4bf | 312 | } |