Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

code c

Uploaded by

luongduan2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

code c

Uploaded by

luongduan2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include<16f877a.

h>
#fuses hs,nowdt
#use delay(clock=4000000)
int maled[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};

int so,hc,hdv,count,batdau,phim;

void main()
{
set_tris_c(0x00);
set_tris_b(0b00011111);
set_tris_d(0b00000000);
setup_timer_0(t0_internal|t0_div_256);//cai dat timer0
set_timer0(61);
so=0;
hc=0;
hdv=0;
output_high(pin_d1);
output_high(pin_d2);
while(1)
{
if(batdau==0)
{
if(input(pin_b0)==0)//start
{
while(input(pin_b0)==0)
{}
enable_interrupts(int_timer0);//cho phap ngat timer0
enable_interrupts(global);//ngat toan cuc
batdau=1;
}

}
else
{
if(input(pin_b1)==0)// stop
{
while(input(pin_b1)==0)
{}
disable_interrupts(int_timer0);//ko cho ngat timer0
disable_interrupts(global);//ko cho ngat toan cuc
so=0;
hc=0;
hdv=0;
batdau=0;
output_high(pin_d1);
output_high(pin_d2);

}
if(input(pin_b2)==0)// reset
{
while(input(pin_b2)==0)
{}
so=0;
hc=so/10;
hdv=so%10;
}
if(input(pin_b3)==1)
{
if(input(pin_b4)==1)
{
if(so==99)
{
so=0;
}
else

so++;
delay_ms(100);
hc=so/10;
hdv=so%10;
}
else
{}

}
else
{}
}

}
}

#int_timer0
void ngattimer0()
{
count++;
if(count==1)
{
output_low(pin_d1);
output_high(pin_d2);
output_c(maled[hc]);

}
else
{
output_high(pin_d1);
output_low(pin_d2);
output_c(maled[hdv]);
count=0;
}
set_timer0(61);
}

You might also like