In mikroc , am using 4Mhz , PIC16F877A when i first started new project , that all i was asked to configure .
That's the complete program straight from MikroC
In mikroc , am using 4Mhz , PIC16F877A when i first started new project , that all i was asked to configure .
That's the complete program straight from MikroC
Actually in the tutorial I've read , here is how the program is done NOTICE THE LAST LINE , and it works , i don't know why it doesn't work on my compiler .
ORIGINAL TUTORIAL CODE :
int i ;
sbit sw at porta.b0 ;
sbit led_1 at porta.b1 ;
sbit led_2 at porta.b2 ;
void main () {
trisa.b0=1;
trisa.b1=0;
trisa.b2=0;
while(1) {
if(sw==1){
for(i=0;i<=5;++i){
I don't know what the fxxxxxx is wrong , program is compiled and nothing works , her is what i get when i want to compile the original tutorial program !
here is another program , this one works but not as supposed to be working , i need to press 3 times the button to light up the led , but whe i simulate it , the led lights up before i press the button .
int x ;
int flag ;
sbit sw at portb.b1 ;
sbit led at portb.b0 ;
void main () {
trisb.b0=0;
trisb.b1=1;
flag=0;
while(1){
if(sw==1&&flag==0){
flag=1 ;
x=x+1 ;
}
if(sw==0){
flag=0;
}
if(x==3){
x=0;
led=1;
delay_ms(500);
led=0;
}
}
}