Beruflich Dokumente
Kultur Dokumente
int cont1=0;
int al=0;
int ac=0;
void main() {
PORTD = 0x00;
while(1){
if(configA==0&&config==0){
ac=0;
if(configA==1){
ac=2;
if(config==1){
ac=1;
switch(ac){
case 0:
display_Hora();
break;
case 1:
config_hora();
break;
case 2:
config_A();
break;
comprobarA();
if(Aoff==1){
sA=-1;
mA=-1;
hA=-1;
pmA=-1;
PORTC = 0x04;
}else { /*Pm es 1, C es 4, Se enciende el LED*/
PORTC = 0x02;
}}
void config_A(){
sA=0;
mA=0;
hA=0;
pmA=0;
pos=1;
while(configA==1){
switch(pos){
PORTB=8;
tabla(mA%10);
PORTB=4;
tabla(mA/10);
if(up==1){
while(up==1);
mA++;
if(mA>59){
mA=0;
if(down==1){
while(down==1);
mA--;
if(mA<0){
mA=59;
break;
PORTB=2;
tabla(hA%10);
PORTB=1;
tabla(hA/10);
if(up==1){
while(up==1);
hA++;
if(hA>11){
hA=0;
if(down==1){
while(down==1);
hA--;
if(hA<0){
hA=11;
break;
case 3: delay_ms(tiempo);
delay_ms(tiempo);
while(up==1){
PORTC = 0x02;
pmA=0;}}
while(down==1){
PORTC = 0x02;
pmA=1;
PORTC = 0x04;
pmA=0;}
break;
if(set==1){
while(set==1);
if(pos>3)
pos=1;
if(pos<1)
pos=3;
delay_ms(tiempo);
cont1++;
if(cont1==2){
contador++;
contador=0;
segundos++;
segundos=0;
minutos++;
horas++;
horas=0;
if(pm==0){
pm=1;
}else {
pm=0;
} }
void config_hora(){
while(config==1){
PORTB = 16;
tabla(decena_s);
if(up==1){
while(up==1); /*Mientras la variable up sea 1*/
segundos++;
if(segundos>59){
segundos=0;
if(down==1){
segundos--;
if(segundos<0){
segundos=59;
break;
decena_m = minutos/10;
PORTB=8;
tabla(unidad_m);
delay_ms(tiempo);
PORTB=4;
tabla(decena_m);
if(up==1){
while(up==1);
minutos++;
if(minutos>59){
minutos=0;
if(down==1){
while(down==1);
minutos--;
if(minutos<0){
minutos=59;
break;
decena_h = horas/10;
PORTB=2;
tabla(unidad_h);
delay_ms(tiempo);
PORTB=1;
tabla(decena_h);
if(up==1){
while(up==1);
horas++;
if(horas>11){
horas=0;
if(down==1){
while(down==1);
horas--;
if(horas<0){
horas=11;
break;
case 3:
while(up==1){
pm=1;
PORTC = 0x04;
pm=0;}}
while(down==1){
PORTC = 0x02;
pm=1;
PORTC = 0x04;
pm=0;}
break;
if(set==1){
while(set==1);
if(pos>3)
pos=0;
}}}
void display_Hora(){
unidad_m = minutos%10;
decena_m = minutos/10;
unidad_h = horas%10;
decena_h = horas/10;
PORTB = 1; /*Decenas de horas*/
tabla(decena_h);
delay_ms(tiempo);
tabla(unidad_h);
delay_ms(tiempo);
tabla(decena_m);
delay_ms(tiempo);
tabla(unidad_m);
delay_ms(tiempo);
tabla(decena_s);
delay_ms(tiempo);
tabla(unidad_s);
delay_ms(tiempo);
contador++;
if(contador==16){
contador=0;
segundos++;
if(segundos==60){
segundos=0;
minutos++;
if(al==1){
PORTC=0x08;}
if(minutos == 60){
minutos=0;
horas++;
if(horas==12){
horas=0;
if(pm==0){
PORTC = 0x02;
pm=1;
}else {
PORTC = 0x04;
pm=0;
}}}}}
void comprobarA(){
if(mA==minutos){
if(hA==horas){
if(pmA==pm){
if(pm==0){
PORTC = 0xC;
}else{
PORTC = 0xA;
}}}
switch(valor){
case 0: PORTD= 192; break; /*1100 0000*/