whats wrong with my counter?
Discussion in "PIC Microcontroller Discussion" started by cezar Jul 22, 2008.
Tue Jul 22 2008, 04:08 am
#include<pic.h>
int B,C,D;
int decode[10]={0,1,2,3,4,5,6,7,8,9};
main()
{
TRISA=0xFF;
TRISE=0x0F;
TRISB=0x00;
TRISC=0x00;
TRISD=0x00;
while(1)
{
if (RA0==1||RE0==1){B=10;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA1==1||RE1==1){B=1;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA2==1||RE2==1){C=2;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA3==1){C=3;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA4==1){D=4;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA5==1){D=5;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
}
}
int B,C,D;
int decode[10]={0,1,2,3,4,5,6,7,8,9};
main()
{
TRISA=0xFF;
TRISE=0x0F;
TRISB=0x00;
TRISC=0x00;
TRISD=0x00;
while(1)
{
if (RA0==1||RE0==1){B=10;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA1==1||RE1==1){B=1;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA2==1||RE2==1){C=2;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA3==1){C=3;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA4==1){D=4;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
if (RA5==1){D=5;PORTB=decode[b];PORTC=decode[C];PORTD=decode[D];}
}
}
Powered by e107 Forum System