Hi i'm trying to build a circuit that tells the time in seconds in four 7 segment displays when a button is being pressed...I'm using a 16F84A... i have used latch enabled decoders .i have assigned the certain button to porta.f0
the problem is when i run the program in Proteus and it only shows 0000..no matter how long i pressed it..when i put count=4546 like a number in the main function it shows that...but it doesnt shpw it when i put it outside the main function..
this is my program
plzzz help me
thx in advance
the problem is when i run the program in Proteus and it only shows 0000..no matter how long i pressed it..when i put count=4546 like a number in the main function it shows that...but it doesnt shpw it when i put it outside the main function..
this is my program
plzzz help me
thx in advance
Rich (BB code):
unsigned int count,count1;
void display(int,int,int,int) ;
void interupt(void)
{
if (intcon.t0if==1)
{
if (porta.f0==1)
{
count1=count1+1;
if (count1==10)
{
count1=0;
count=count++;
if (count ==9999)
{
count=0;
}
}
}
}
else if(porta.f1==1)
{
count1=0;
count=0;
}
intcon.t0if=0;
}
void main()
{
int a,b,c,d;
intcon= 0b10100000;
option_reg= 0b00000111;
trisa=0b11111;
trisb=0b000000000;
count1=count=0;
while(1)
{
a=count/1000;
b=((count%1000)/100);
c=(((count%1000)%100)/10);
d=((((count%1000)%100)%10)/1);
display(a,b,c,d);
}
}
void display(int x,int y,int z,int w)
{
if (x==0)
{
portb=0b00000001;
}
if (x==1)
{
portb=0b00010001;
}
if (x==2)
{
portb=0b00100001;
}
if (x==3)
{
portb=0b00110001;
}
if (x==4)
{
portb=0b01000001;
}
if (x==5)
{
portb=0b01010001;
}
if (x==6)
{
portb=0b01100001;
}
if (x==7)
{
portb=0b01110001;
}
if (x==8)
{
portb=0b10000001;
}
if (x==9)
{
portb=0b10010001;
}
if (y==0)
{
portb=0b00000010;
}
if (y==1)
{
portb=0b00010010;
}
if (y==2)
{
portb=0b00100010;
}
if (y==3)
{
portb=0b00110010;
}
if (y==4)
{
portb=0b01000010;
}
if (y==5)
{
portb=0b01010010;
}
if (y==6)
{
portb=0b01100010;
}
if (y==7)
{
portb=0b01110010;
}
if (y==8)
{
portb=0b10000010;
}
if (y==9)
{
portb=0b10010010;
}
if (z==0)
{
portb=0b00000100;
}
if (z==1)
{
portb=0b00010100;
}
if (z==2)
{
portb=0b00100100;
}
if (z==3)
{
portb=0b00110100;
}
if (z==4)
{
portb=0b01000100;
}
if (z==5)
{
portb=0b01010100;
}
if (z==6)
{
portb=0b01100100;
}
if (z==7)
{
portb=0b01110100;
}
if (z==8)
{
portb=0b10000100;
}
if (z==9)
{
portb=0b10010100;
}
if (w==0)
{
portb=0b00001000;
}
if (w==1)
{
portb=0b00011000;
}
if (w==2)
{
portb=0b00101000;
}
if (w==3)
{
portb=0b00111000;
}
if (w==4)
{
portb=0b01001000;
}
if (w==5)
{
portb=0b01011000;
}
if (w==6)
{
portb=0b01101000;
}
if (w==7)
{
portb=0b01111000;
}
if (w==8)
{
portb=0b10001000;
}
if (w==9)
{
portb=0b10011000;
}
}
Last edited by a moderator: