Professional Documents
Culture Documents
h>
#include"delay.c"
__CONFIG(0x3f72);
int x;
void main()
TRISA=0x00;
TRISD=0x00;
ADCON1=0x07;
while(1)
if(x == 10)
x=0;
single++;
if(single>9)
{
single=0;
ten++;
if(ten>9)
ten=0;
hun++;
if(hun>9)
hun=0;
thou++;
if(thou>9)
thou=0;
x++;
send_seg(thou,hun,ten,single);
void send_seg(unsigned char thou,unsigned char hun,unsigned char ten,unsigned char single)
if(n==1)
{
PORTA=0x07;
PORTD=a[single];
n=2;
DelayMs(5);
else if(n==2)
PORTA=0x0b;
PORTD=a[ten];
n=3;
DelayMs(5);
else if(n==3)
PORTA=0x0d;
PORTD=a[hun];
n=0;
DelayMs(5);
else
PORTA=0x0e;
PORTD=a[thou];
n=1;
DelayMs(5);