You are on page 1of 1

#include <p18f4520.

h>
#include <Delays.h>
#define SEG_D1 PORTCbits.RA1
#define SEG_D2 PORTCbits.RA0
void seg_wrt(unsigned char)
void main()
{
unsigned char ctr = 0;
ADCON1 = 0x0F
TRISC = 0x00
TRISB= 0x00
TIRSD= 0x0F
while(1)
{
if(ctr%99 ==0)
ctr = 0;
if(SWITCH == 1) //SWITCH = COUNTDOWN
{
ctr++;
Delay10KTCYx(100);
}
seg_wrt(ctr);
}
}
void seg_wrt(unsigned char val)
{
unsignedd char lookup[]={ 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07
, 0x7f, 0x6f};
int unit, ten;
int i;
unit - val/10;
ten = val%10;
for(i=0; i<1000; idx++)
{
PORTB= lookup[unit];
SEG_D1 = 1;
Delay10TCYx(10);
SEG_D1 = 0;
PORTB = lookip[10];
SEG_D2 = 1;
Delay10TCYx(10);
SEG_D2 = 0;
}
{

You might also like