![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
alarma configurable y se prende y apaga con control remoto
Dependencies: Debounced Pulse1 QEI RTC-DS1307 TextLCD mbed
Diff: main.cpp
- Revision:
- 0:31bb391d0545
diff -r 000000000000 -r 31bb391d0545 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 01 20:55:03 2018 +0000 @@ -0,0 +1,1308 @@ +#include "mbed.h" +#include "DebouncedIn.h" +#include "TextLCD.h" +#include "QEI.h" +#include "Rtc_Ds1307.h" +#include <Pulse1.h> +Serial pc(USBTX, USBRX); +PulseInOut irda(PTD5); +TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 +Rtc_Ds1307 rtc(PTE0, PTE1); +QEI wheel (PTD7, PTD6, NC, 100); + +DebouncedIn button_enco(PTC5); + +DigitalOut led(LED1); + +int C1=0x0C; +int m=0; +int Conf=0; // 0: Alarma y 1:Reloj +int Lugar=0; // Definen el punto en el cual va el programa +int i; +int visual=1; +int ac=1; +int activ1=0; +int ac2=0; +int ac3=0; +int ac4=0; +int ac5=0; +int ac6=0; +int ac7=0; +int alarma1=0; +int alarma2=0; +int alarma3=0; +int alarma4=0; +int alarma5=0; +int alarma6=0; +int alarma7=0; +int selec=1; +int n=0; +int comp1=0; +int comp2=0; +int comp3=0; +int comp4=0; +int comp5=0; +int comp6=0; +int comp7=0; +int comp8=0; +int header=0; +int mode=1; +int j=0; +int k=0; +int numP[35]; +int numP_nor[35]; +int numb=32; +int boton1[32]= {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,1,0,0,1,1,1,1,1}; //1 +int boton2[32]= {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1}; //2 +int boton3[32]= {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,1,1,0,1,1,1,1}; //3 +int boton4[32]= {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,1,0,1,0,1,1,1,1}; //4 +int boton5[32]= {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,1,1}; //5 +int boton6[32]= {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,1}; //6 +int boton7[32]= {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,1,1,1,1,1,0,1}; //7 +int boton8[32]= {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,1,1,0,1,1,1,1,1}; + +int main() +{ + Rtc_Ds1307::Time_rtc tm = {}; + Rtc_Ds1307::Time_rtc Alarm = {}; + Rtc_Ds1307::Time_rtc Alarm1 = {}; + Rtc_Ds1307::Time_rtc Alarm2 = {}; + Rtc_Ds1307::Time_rtc Alarm3 = {}; + Rtc_Ds1307::Time_rtc Alarm4 = {}; + Rtc_Ds1307::Time_rtc Alarm5 = {}; + Rtc_Ds1307::Time_rtc Alarm6 = {}; + lcd.cls(); + lcd.writeCommand(C1);//escribimos un comando segun el manual del modulo LCD + + lcd.locate(0,0); + lcd.printf("--Alarma --Hora"); + + rtc.getTime(tm); //lee el tiempo del DS1307 + + while(1) + { + switch (Lugar) + { + case 0: + led= 1; + m=wheel.getPulses(); // m son los datos del encoder + if(m!=0 && Conf==0){ + Conf=1; + wheel.reset(); + m=0; + } + + if(m!=0 && Conf==1){ + Conf=0; + wheel.reset(); + m=0; + } + + if(Conf==0){ + + lcd.locate(11,0); + lcd.printf("-"); + lcd.locate(1,0); + lcd.printf(">"); + lcd.locate(0,1); + wait(0.1); + + } + + if(Conf==1){ + + lcd.locate(1,0); + lcd.printf("-"); + lcd.locate(11,0); + lcd.printf(">"); + lcd.locate(0,1); + wait(0.1); + } + + if (button_enco.falling()){ //si se pulsa boton encoder + Lugar=1; + m=0; + } + + break; + + case 1: + switch(i) + { + case 0: + + + if(Conf==0) + { + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Config. Alarma "); + wait(1); + i++; + m=0; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Dia: "); + tm.date=1; + } + + if(Conf==1) + { + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Config. hora "); + wait(1); + i++; + m=0; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Dia: "); + + } + + break; + + case 1: + m=wheel.getPulses(); + if (m!=0) + { + tm.date=tm.date+m; + if(tm.date>31) + { + tm.date=31; + } + if(tm.date<1) + { + tm.date=1; + } + + wheel.reset(); + m=0; + } + lcd.locate(5,0); + lcd.printf("%02d",tm.date); + + if (button_enco.falling()) + { + i++; + m=0; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Mes: "); + //tm.mon=1; + } + + break; + + case 2: + m=wheel.getPulses(); + if (m!=0) + { + tm.mon=tm.mon+m; + if(tm.mon>12) + { + tm.mon=12; + } + if(tm.mon<1) + { + tm.mon=1; + } + + wheel.reset(); + m=0; + } + lcd.locate(5,0); + lcd.printf("%02d",tm.mon); + + if (button_enco.falling()) + { + i++; + m=0; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Year: "); + + } + + break; + + case 3: + m=wheel.getPulses(); + if (m!=0) + { + tm.year=tm.year+m; + + if(tm.year<2000) + { + tm.year=2000; + } + + wheel.reset(); + m=0; + } + lcd.locate(6,0); + lcd.printf("%02d",tm.year); + + if (button_enco.falling()) + { + i++; + m=0; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Hora: "); + + } + + break; + + case 4: + m=wheel.getPulses(); + + if (m!=0) + { + tm.hour=tm.hour + m; + if(tm.hour>23) + { + tm.hour=23; + } + if(tm.hour<0) + { + tm.hour=0; + } + + wheel.reset(); + m=0; + } + lcd.locate(6,0); + lcd.printf("%02d",tm.hour); + + if (button_enco.falling()) + { + i++; + m=0; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Minuto: "); + //tm.min=0; + } + + break; + + case 5: + m=wheel.getPulses(); + if (m!=0) + { + tm.min=tm.min+m; + if(tm.min>59) + { + tm.min=59; + } + if(tm.min<0) + { + tm.min=0; + } + + wheel.reset(); + m=0; + } + lcd.locate(8,0); + lcd.printf("%02d",tm.min); + + if (button_enco.falling()) + { + i++; + m=0; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Segundo: "); + //tm.sec=0; + } + + break; + + + case 6: + m=wheel.getPulses(); + if (m!=0) + { + tm.sec=tm.sec+m; + if(tm.sec>59) + { + tm.sec=59; + } + if(tm.sec<0) + { + tm.sec=0; + } + + wheel.reset(); + m=0; + } + lcd.locate(9,0); + lcd.printf("%02d",tm.sec); + + if (button_enco.falling()) + { + /////////////////// + if(Conf==0) + { + + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Alarma:"); + i++; + m=0; + + } + + if(Conf==1) + { + rtc.setTime(tm, false, false); + rtc.startClock(); + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Hora Config. "); + wait(1); + i=0; + m=0; + Lugar=0; + lcd.locate(0,0); + lcd.printf("--Alarma --Hora"); + } + + /////////////////// + } + + break; + case 7: + m=wheel.getPulses(); + if (m!=0) + { + selec=selec+m; + if(selec>7) + { + selec=7; + } + if(selec<1) + { + selec=1; + } + + wheel.reset(); + m=0; + } + lcd.locate(9,0); + lcd.printf("%02d",selec); + + if (button_enco.falling()) + { + i++; + m=0; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("%02d seleccionada",selec); + //tm.sec=0; + } + break; + + case 8: + if (selec==1) + { + Alarm=tm; + lcd.cls(); + lcd.locate(0,0); + i=0; + m=0; + Lugar++; + } + if (selec==2) + { + Alarm1=tm; + lcd.cls(); + lcd.locate(0,0); + i=0; + m=0; + Lugar++; + } + if (selec==3) + { + Alarm2=tm; + lcd.cls(); + lcd.locate(0,0); + i=0; + m=0; + Lugar++; + } + if (selec==4) + { + Alarm3=tm; + lcd.cls(); + lcd.locate(0,0); + i=0; + m=0; + Lugar++; + } + if (selec==5) + { + Alarm4=tm; + lcd.cls(); + lcd.locate(0,0); + i=0; + m=0; + Lugar++; + } + if (selec==6) + { + Alarm5=tm; + lcd.cls(); + lcd.locate(0,0); + i=0; + m=0; + Lugar++; + } + if (selec==7) + { + Alarm6=tm; + lcd.cls(); + lcd.locate(0,0); + i=0; + m=0; + Lugar++; + } + + break; + + } + break; + + case 2: + led=1; + rtc.getTime(tm); + m=wheel.getPulses(); + if (m!=0) + { + visual=visual+m; + if(visual>10) + { + visual=1; + } + if(visual<1) + { + visual=10; + } + + wheel.reset(); + m=0; + } + if(visual==1) + { + + lcd.locate(0,0); + lcd.printf("Hora: "); + lcd.locate(8,0); + lcd.printf("%02d:",tm.hour); + lcd.printf("%02d:",tm.min); + lcd.printf("%02d",tm.sec); + + lcd.locate(0,1); + lcd.printf("%02d/",tm.mon); + lcd.printf("%02d/",tm.date); + lcd.printf("%02d",tm.year); + lcd.printf(","); + if(activ1==1) + { + lcd.printf("1"); + } + + if(ac2==1) + { + lcd.printf("2"); + } + if(ac3==1) + { + lcd.printf("3"); + } + if(ac4==1) + { + lcd.printf("4"); + } + if(ac5==1) + { + lcd.printf("5"); + } + if(ac6==1) + { + lcd.printf("6"); + } + if(ac7==1) + { + lcd.printf("7"); + } + wait(0.1); + + ////// + + } + + if(visual==2) + { + lcd.locate(0,0); + lcd.printf("Alarma1 "); + lcd.locate(8,0); + lcd.printf("%02d:",Alarm.hour); + lcd.printf("%02d:",Alarm.min); + lcd.printf("%02d",Alarm.sec); + + + lcd.locate(0,1); + lcd.printf("%02d/",Alarm.mon); + lcd.printf("%02d/",Alarm.date); + lcd.printf("%02d",Alarm.year); + + if (activ1==0) + { + lcd.printf(" off"); + } + if (activ1==1) + { + lcd.printf(" on"); + } + wait(0.1); + lcd.cls(); + + } + if(visual==3) + { + lcd.locate(0,0); + lcd.printf("Alarma2 "); + lcd.locate(8,0); + lcd.printf("%02d:",Alarm1.hour); + lcd.printf("%02d:",Alarm1.min); + lcd.printf("%02d",Alarm1.sec); + + + lcd.locate(0,1); + lcd.printf("%02d/",Alarm1.mon); + lcd.printf("%02d/",Alarm1.date); + lcd.printf("%02d",Alarm1.year); + + if (ac2==0) + { + lcd.printf(" off"); + } + if (ac2==1) + { + lcd.printf(" on"); + } + wait(0.1); + lcd.cls(); + + } + if(visual==4) + { + lcd.locate(0,0); + lcd.printf("Alarma3 "); + lcd.locate(8,0); + lcd.printf("%02d:",Alarm2.hour); + lcd.printf("%02d:",Alarm2.min); + lcd.printf("%02d",Alarm2.sec); + + + lcd.locate(0,1); + lcd.printf("%02d/",Alarm2.mon); + lcd.printf("%02d/",Alarm2.date); + lcd.printf("%02d",Alarm2.year); + + if (ac3==0) + { + lcd.printf(" off"); + } + if (ac3==1) + { + lcd.printf(" on"); + } + wait(0.1); + lcd.cls(); + + } + if(visual==5) + { + lcd.locate(0,0); + lcd.printf("Alarma4 "); + lcd.locate(8,0); + lcd.printf("%02d:",Alarm3.hour); + lcd.printf("%02d:",Alarm3.min); + lcd.printf("%02d",Alarm3.sec); + + + lcd.locate(0,1); + lcd.printf("%02d/",Alarm3.mon); + lcd.printf("%02d/",Alarm3.date); + lcd.printf("%02d",Alarm3.year); + + if (ac4==0) + { + lcd.printf(" off"); + } + if (ac4==1) + { + lcd.printf(" on"); + } + wait(0.1); + lcd.cls(); + + } + if(visual==6) + { + lcd.locate(0,0); + lcd.printf("Alarma5 "); + lcd.locate(8,0); + lcd.printf("%02d:",Alarm4.hour); + lcd.printf("%02d:",Alarm4.min); + lcd.printf("%02d",Alarm4.sec); + + + lcd.locate(0,1); + lcd.printf("%02d/",Alarm4.mon); + lcd.printf("%02d/",Alarm4.date); + lcd.printf("%02d",Alarm4.year); + + if (ac5==0) + { + lcd.printf(" off"); + } + if (ac5==1) + { + lcd.printf(" on"); + } + wait(0.1); + lcd.cls(); + + } + if(visual==7) + { + lcd.locate(0,0); + lcd.printf("Alarma6 "); + lcd.locate(8,0); + lcd.printf("%02d:",Alarm5.hour); + lcd.printf("%02d:",Alarm5.min); + lcd.printf("%02d",Alarm5.sec); + + + lcd.locate(0,1); + lcd.printf("%02d/",Alarm5.mon); + lcd.printf("%02d/",Alarm5.date); + lcd.printf("%02d",Alarm5.year); + if (ac6==0) + { + lcd.printf(" off"); + } + if (ac6==1) + { + lcd.printf(" on"); + } + wait(0.1); + lcd.cls(); + + } + if(visual==8) + { + lcd.locate(0,0); + lcd.printf("Alarma7 "); + lcd.locate(8,0); + lcd.printf("%02d:",Alarm6.hour); + lcd.printf("%02d:",Alarm6.min); + lcd.printf("%02d",Alarm6.sec); + + + lcd.locate(0,1); + lcd.printf("%02d/",Alarm6.mon); + lcd.printf("%02d/",Alarm6.date); + lcd.printf("%02d",Alarm6.year); + + if (ac7==0) + { + lcd.printf(" off"); + } + if (ac7==1) + { + lcd.printf(" on"); + } + wait(0.1); + lcd.cls(); + + } + if (visual==9) + { + lcd.locate(0,0); + lcd.printf("Nueva alarma"); + wait(0.1); + lcd.cls(); + if (button_enco.falling()) + { + Conf=0; + Lugar=1; + i=0; + } + } + if(visual==10) + { + lcd.locate(0,0); + lcd.printf("guardar"); + wait(0.1); + lcd.cls(); + if (button_enco.falling()) + { + lcd.cls(); + Lugar=3; + } + } + if( (tm.date==Alarm.date)&&(tm.mon==Alarm.mon)&&(tm.year==Alarm.year)&&(tm.hour==Alarm.hour)&&(tm.min==Alarm.min)&&(tm.sec==Alarm.sec)&&(activ1==1) ) + { + Lugar=4; + alarma1=1; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Alarma 1 Activa"); + m=0; + } + if( (tm.date==Alarm1.date)&&(tm.mon==Alarm1.mon)&&(tm.year==Alarm1.year)&&(tm.hour==Alarm1.hour)&&(tm.min==Alarm1.min)&&(tm.sec==Alarm1.sec)&&(ac2==1) ) + { + Lugar=4; + alarma2=1; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Alarma 2 Activa"); + m=0; + } + if( (tm.date==Alarm2.date)&&(tm.mon==Alarm2.mon)&&(tm.year==Alarm2.year)&&(tm.hour==Alarm2.hour)&&(tm.min==Alarm2.min)&&(tm.sec==Alarm2.sec)&&(ac3==1) ) + { + Lugar=4; + alarma3=1; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Alarma 3 Activa"); + m=0; + } + if( (tm.date==Alarm3.date)&&(tm.mon==Alarm3.mon)&&(tm.year==Alarm3.year)&&(tm.hour==Alarm3.hour)&&(tm.min==Alarm3.min)&&(tm.sec==Alarm3.sec)&&(ac4==1)) + { + Lugar=4; + alarma4=1; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Alarma 4 Activa"); + m=0; + } + if( (tm.date==Alarm4.date)&&(tm.mon==Alarm4.mon)&&(tm.year==Alarm4.year)&&(tm.hour==Alarm4.hour)&&(tm.min==Alarm4.min)&&(tm.sec==Alarm4.sec)&&(ac5==1) ) + { + Lugar=4; + alarma5=1; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Alarma 5 Activa"); + m=0; + } + if( (tm.date==Alarm5.date)&&(tm.mon==Alarm5.mon)&&(tm.year==Alarm5.year)&&(tm.hour==Alarm5.hour)&&(tm.min==Alarm5.min)&&(tm.sec==Alarm5.sec)&&(ac6==1) ) + { + Lugar=4; + alarma6=1; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Alarma 6 Activa"); + m=0; + } + if( (tm.date==Alarm6.date)&&(tm.mon==Alarm6.mon)&&(tm.year==Alarm6.year)&&(tm.hour==Alarm6.hour)&&(tm.min==Alarm6.min)&&(tm.sec==Alarm6.sec)&&(ac7==1) ) + { + Lugar=4; + alarma7=1; + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Alarma 7 Activa"); + m=0; + } + + + break; + case 3: + switch (ac){ + case 1: + header = irda.read_high_us(); + if(header>3500) + { + ac=2; + } + break; + case 2: + + for(j=0;j<numb;++j) + { + numP[j] = irda.read_high_us(); //funcion para leer un pulso alto + } + header=0; + for(j=0;j<numb;++j) + { + if(numP[j]<1000) + { + numP_nor[j]=0; + } + if(numP[j]>1000) + { + numP_nor[j]=1; + } + pc.printf("%d,",numP_nor[j]); + } + pc.printf("\n"); + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton1[j]) + { + n=0; + } + else + { + n=1; + } + comp1=comp1+n; + n=0; + } + + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton2[j]) + { + n=0; + } + else + { + n=1; + } + comp2=comp2+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton3[j]) + { + n=0; + } + else + { + n=1; + } + comp3=comp3+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton4[j]) + { + n=0; + } + else + { + n=1; + } + comp4=comp4+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton5[j]) + { + n=0; + } + else + { + n=1; + } + comp5=comp5+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton6[j]) + { + n=0; + } + else + { + n=1; + } + comp6=comp6+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton7[j]) + { + n=0; + } + else + { + n=1; + } + comp7=comp7+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton8[j]) + { + n=0; + } + else + { + n=1; + } + comp8=comp8+n; + n=0; + } + if ((comp1==0)) + { + pc.printf("Oprimio 1\n"); + if(activ1==0) + { + activ1=1; + lcd.cls(); + lcd.printf("Alarma 1: on"); + } + else if(activ1==1) + { + activ1=0; + lcd.cls(); + lcd.printf("Alarma 1: off"); + } + + } + if ((comp2==0)) + { + pc.printf("Oprimio 2\n"); + if(ac2==0) + { + ac2=1; + lcd.cls(); + lcd.printf("Alarma 2: on"); + } + else if(ac2==1) + { + ac2=0; + lcd.cls(); + lcd.printf("Alarma 2: off"); + } + + } + if ((comp3==0)) + { + + pc.printf("Oprimio 3\n"); + if(ac3==0) + { + ac3=1; + lcd.cls(); + lcd.printf("Alarma 3: on"); + } + else if(ac3==1) + { + ac3=0; + lcd.cls(); + lcd.printf("Alarma 3: off"); + } + + } + if ((comp4==0)) + { + + pc.printf("Oprimio 4\n"); + if(ac4==0) + { + ac4=1; + lcd.cls(); + lcd.printf("Alarma 4: on"); + } + else if(ac4==1) + { + ac4=0; + lcd.cls(); + lcd.printf("Alarma 4: off"); + } + + } + if ((comp5==0)) + { + + pc.printf("Oprimio 5\n"); + if(ac5==0) + { + ac5=1; + lcd.cls(); + lcd.printf("Alarma 5: on"); + } + else if(ac5==1) + { + ac5=0; + lcd.cls(); + lcd.printf("Alarma 5: off"); + } + + } + if ((comp6==0)) + { + + pc.printf("Oprimio 6\n"); + if(ac6==0) + { + ac6=1; + lcd.cls(); + lcd.printf("Alarma 6: on"); + } + else if(ac6==1) + { + ac6=0; + lcd.cls(); + lcd.printf("Alarma 6: off"); + } + + } + if ((comp7==0)) + { + + pc.printf("Oprimio 7\n"); + if(ac7==0) + { + ac7=1; + lcd.cls(); + lcd.printf("Alarma 7: on"); + } + else if(ac7==1) + { + ac7=0; + lcd.cls(); + lcd.printf("Alarma 7: off"); + } + + } + if ((comp8==0)) + { + Lugar=2; + visual=1; + } + comp1=0; + comp2=0; + comp3=0; + comp4=0; + comp5=0; + comp6=0; + comp7=0; + comp8=0; + n=0; + ac=1; + } + break; + + case 4: + led=0; + switch (mode){ + case 1: + header = irda.read_high_us(); + if(header>3500) + { + mode=2; + } + break; + case 2: + + for(j=0;j<numb;++j) + { + numP[j] = irda.read_high_us(); //funcion para leer un pulso alto + } + header=0; + for(j=0;j<numb;++j) + { + if(numP[j]<1000) + { + numP_nor[j]=0; + } + if(numP[j]>1000) + { + numP_nor[j]=1; + } + pc.printf("%d,",numP_nor[j]); + } + pc.printf("\n"); + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton1[j]) + { + n=0; + } + else + { + n=1; + } + comp1=comp1+n; + n=0; + } + + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton2[j]) + { + n=0; + } + else + { + n=1; + } + comp2=comp2+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton3[j]) + { + n=0; + } + else + { + n=1; + } + comp3=comp3+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton4[j]) + { + n=0; + } + else + { + n=1; + } + comp4=comp4+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton5[j]) + { + n=0; + } + else + { + n=1; + } + comp5=comp5+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton6[j]) + { + n=0; + } + else + { + n=1; + } + comp6=comp6+n; + n=0; + } + for (j=0;j<numb;++j) + { + if(numP_nor[j]==boton7[j]) + { + n=0; + } + else + { + n=1; + } + comp7=comp7+n; + n=0; + } + if ((comp1==0)&&(alarma1==1)) + { + alarma1=0; + Lugar=2; + pc.printf("Oprimio 1\n"); + lcd.cls(); + lcd.printf("Alarma 1: off"); + wait(2); + lcd.cls(); + + } + if ((comp2==0)&&(alarma2==1)) + { + alarma2=0; + Lugar=2; + pc.printf("Oprimio 2\n"); + lcd.cls(); + lcd.printf("Alarma 2: off"); + wait(2); + lcd.cls(); + } + if ((comp3==0)&&(alarma3==1)) + { + alarma3=0; + Lugar=2; + pc.printf("Oprimio 3\n"); + lcd.cls(); + lcd.printf("Alarma 3: off"); + wait(2); + lcd.cls(); + } + if ((comp4==0)&&(alarma4==1)) + { + alarma4=0; + Lugar=2; + pc.printf("Oprimio 4\n"); + lcd.cls(); + lcd.printf("Alarma 4: off"); + wait(2); + lcd.cls(); + } + if ((comp5==0)&&(alarma5==1)) + { + alarma5=0; + Lugar=2; + pc.printf("Oprimio 5\n"); + lcd.cls(); + lcd.printf("Alarma 5: off"); + wait(2); + lcd.cls(); + } + if ((comp6==0)&&(alarma6==1)) + { + alarma6=0; + Lugar=2; + pc.printf("Oprimio 6\n"); + lcd.cls(); + lcd.printf("Alarma 6: off"); + wait(2); + lcd.cls(); + } + if ((comp7==0)&&(alarma7==1)) + { + alarma7=0; + Lugar=2; + pc.printf("Oprimio 7\n"); + lcd.cls(); + lcd.printf("Alarma 7: off"); + wait(2); + lcd.cls(); + } + comp1=0; + comp2=0; + comp3=0; + comp4=0; + comp5=0; + comp6=0; + comp7=0; + n=0; + mode=1; + } + + } +} +}