unsigned char counter,tmp;
unsigned char umili,dmili,cmili, mmili, num, umili1, dmili1, cmili1, mmili1,umili2,dmili2,cmili2, mmili2 ;
int numero,numero1, mnum, mnum1;
unsigned char seg7[]={0x63,0x02,0x5B,0x4F,0x66,0x6D,
0x7D,0x07,0x7f,0x6f,0x77,
0x7C,0x39,0x5E,0x79,0x71};
unsigned char seg71[]={0x5C,0x04,0x5B,0x4F,0x66,0x6D,
0x7D,0x07,0x7f,0x6f,0x77,
0x7C,0x39,0x5E,0x79,0x71};
void separa_digitos(void);
void muestra_digitos(void);
void separa_digitos1(void);
void muestra_digitos1(void);
void main() {
ADCON1 =0x0F;
TRISC=0;
TRISD=0;
numero=0;
PORTC=0;
PORTD=0;
while(1)
{
separa_digitos();
muestra_digitos();
numero++;
if(numero==256)
{
numero=0;
}
separa_digitos1();
muestra_digitos1();
numero1--;
if(numero1==0)
{
numero1=255;
}
}
}
void muestra_digitos(void)
{
num=seg7[mmili];
PORTC=0x00;
PORTD=num;
Delay_ms(2);
num=seg7[cmili];
PORTC=0x01;
PORTD=num;
Delay_ms(2);
num=seg7[dmili];
PORTC=0x02;
PORTD=num;
Delay_ms(2);
num=seg7[umili];
PORTC=0x03;
PORTD=num;
Delay_ms(2);
num=seg7[mmili2];
PORTC=0x04;
PORTD=num;
Delay_ms(2);
num=seg7[cmili2];
PORTC=0x05;
PORTD=num;
Delay_ms(2);
num=seg7[dmili2];
PORTC=0x06;
PORTD=num;
Delay_ms(2);
num=seg7[umili2];
PORTC=0x07;
PORTD=num;
Delay_ms(2);
}
void separa_digitos(void)
{
mnum=numero;
umili2=(unsigned char)mnum%2;
mnum=mnum/2;
dmili2=(unsigned char)mnum%2;
mnum=mnum/2;
cmili2=(unsigned char)mnum%2;
mnum=mnum/2;
mmili2=(unsigned char)mnum%2;
mnum=mnum/2;
umili=(unsigned char)mnum%2;
mnum=mnum/2;
dmili=(unsigned char)mnum%2;
mnum=mnum/2;
cmili=(unsigned char)mnum%2;
mnum=mnum/2;
mmili=(unsigned char)mnum%2;
}
void muestra_digitos1(void)
{
num=seg7[mmili]|seg71[mmili];
PORTC=0x00;
PORTD=num;
Delay_ms(2);
num=seg71[cmili];
PORTC=0x01;
PORTD=num;
Delay_ms(2);
num=seg71[dmili];
PORTC=0x02;
PORTD=num;
Delay_ms(2);
num=seg71[umili];
PORTC=0x03;
PORTD=num;
Delay_ms(2);
num=seg71[mmili2];
PORTC=0x04;
PORTD=num;
Delay_ms(2);
num=seg71[cmili2];
PORTC=0x05;
PORTD=num;
Delay_ms(2);
num=seg71[dmili2];
PORTC=0x06;
PORTD=num;
Delay_ms(2);
num=seg71[umili2];
PORTC=0x07;
PORTD=num;
Delay_ms(2);
}
void separa_digitos1(void)
{
mnum1=numero1;
umili2=(unsigned char)mnum1%2;
mnum1=mnum1/2;
dmili2=(unsigned char)mnum1%2;
mnum1=mnum1/2;
cmili2=(unsigned char)mnum1%2;
mnum1=mnum1/2;
mmili2=(unsigned char)mnum1%2;
mnum1=mnum1/2;
umili=(unsigned char)mnum1%2;
mnum1=mnum1/2;
dmili=(unsigned char)mnum1%2;
mnum1=mnum1/2;
cmili=(unsigned char)mnum1%2;
mnum1=mnum1/2;
mmili=(unsigned char)mnum1%2;
}
No hay comentarios.:
Publicar un comentario