Hello everyone here .
The program is like this :
Using a microcontroller (pic16f84a) , 4 leds on port b , and one button on port a .
when i press the 1st time , the led1 lights up , when i push 2nd time , led2 lights up and the first shuts down , and so on for the 4th one , after that when i press the button everything is off , and the cycle starts again .
This is my vision of the program , but unfortunately it didn't work out :
Please share your ideas .
The program is like this :
Using a microcontroller (pic16f84a) , 4 leds on port b , and one button on port a .
when i press the 1st time , the led1 lights up , when i push 2nd time , led2 lights up and the first shuts down , and so on for the 4th one , after that when i press the button everything is off , and the cycle starts again .
This is my vision of the program , but unfortunately it didn't work out :
Please share your ideas .
Rich (BB code):
#define start porta.b0
#define led1 portb.b0
#define led2 portb.b1
#define led3 portb.b2
#define led4 portb.b3
int x0,x1,x2,x3;
void main() {
porta=0x00;
portb=0xff;
trisa=0xff;
trisb=0x00;
x0=1;x1=0;x2=0;x3=0;
while(1){
if((start==1)&&(x0==1)){
x0=0;
x1=1;
led1=0;
}
if((start==1)&&(x1==1)){
x1=0;
x2=1;
led1=1;
led2=0;
}
if((start==1)&&(x2==1)){
x2=0;
x3=1;
led2=1;
led3=0;
}
if((start==1)&&(x3==1)){
x3=0;
x0=1;
led3=1;
led4=0;
}
}
}
Last edited: