Código fuente del microcontrolador Qt control
#Definir carácter sin firmar uchar
código uchar ledtab[]={0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f }; //0-9
Carácter sin firmar seg=0, min=0, hora=12, escaneado
Clave de carácter sin firmar, flashbit, punto, hora , veces = 0;
Carácter sin firmar disdat[4];
sbit keyqt=p3^0;
sbit keyxz=p3^1;
sbit keytz=p3^2;
Discusión no válida()
{
disdat[0]= min % 10;
disdat [ 1]= min/10;
disdat[2]=hora % 10;
disdat[3]=hora/10;
}
}
p>El vacío T0ISR() interrumpe el temporizador de 1//segundo
{
TR0 = 0;
TH0 = 0x3c
TL0 = 0xb0
TR0 = 1;
tiempo++;
else punto = 1;
if (tiempo==20)
{
tiempo = 0;
seg++;
if(segundos & gt59)
{
seg = 0
min++; p>si(min & gt; 59)
{
hora++;
si (hora>23) hora = 0;
}
}
}
dischg();
}
Interrupción t1ISR() nula 3// mostrar
{
tr 1 = 0
th 1 = 0x EC
TL 1 = 0x 78; >
tr 1 = 1;
veces++;
if (veces & gt; = 50) {número de veces = 0;
Interruptor (led de escaneo)
{
Caso 0:
P2 = 0x 01;
P0 = ~ pestaña led [disdat[3]];
if((t flash == 0)& amp;& amp(flash bit == 1))P0 = ~ pestaña led[0x 10];
Pausa;
Caso 1:
P2 = 0x 02;
if(punto)P0 = ~(ledtab[disdat[2]]| 0x 80);
else P0 = ~ ledtab[disdat[2]];
if((t flash = = 0)& amp;& amp(bit flash = = 1 ))P0 = ~ pestaña led[ 0x 10];
Romper;
Caso 2:
P2 = 0x 04;
P0 = ~ pestaña led[disdat[ 1]];
if((t flash == 0)& amp;& amp(flash bit == 2))P
0 = ~ pestaña led[0x 10];
Romper;
Caso 3:
P2 = 0x 08;
P0 = ~ pestaña led[disdat[0]];
if((t flash == 0)& amp; & amp(flash bit == 2))P0 = ~ pestaña led[0x 10];
Pausa;
Predeterminado: pausa
}
led de escaneo++;
% escaneado = 4; p>
p>
}
Principal()
{
TMOD = 0x 11;
TH0 = 0x3c
TL0 = 0xb0
ésimo 1 = 0x EC;
TL 1 = 0x 78;
EA = 1; p>
tr 1 = 1;
ET0 = 1;
et 1 = 1
seg = 0; >min = 0;
Hora = 0;
bit de flash = 0;
led de escaneo = 0; ;
t flash = 0
punto = 1
dischg()
mientras(1)
{
//flash(); //Flash
If (keyqt = = 0)//p3.0 iniciar y detener
{
mientras(tecla Qt = = 0);
TR0 = ~ TR0
bit flash = 0;
}
Si (keyxz = = 0)//p3.1, seleccione tiempo y minutos.
{
mientras(clave xz = = 0);
TR0 = 0;
bit flash++;
if(bit flash & gt; 2){ bit flash = 0; TR0 = 1;}
}
if(keytz = = 0)//número de modulación p>
} p>
{
mientras(clave tz = = 0);
if(flashbit==1)
{
hora++;
si (hora & gt23) hora = 0;
}
si (flashbit==2) p>
{
min++;
if(min & gt;59)min = 0;
}
dischg ();
}
}
}