Hi,
I am new in micro-controller programming and starting a new project on 4 LED blinking using MikroC PRO for PIC v5.6.1. I choose PIC-16F877A for this project.
I want to blink the 4 LED sequentially (24 times clock-wise and another 24 times anti clock-wise) when the Push Button is pressed.
I also used Proteus Professional for checking my program. I see that my code is working good in Proteus Professional.
No problem arise when the .hex code is burnt on the PIC16F877A. Burn successfully!
But a problem arise when the push button is pressed. 4 LED blink sequentially (first for loop infinitely) but need still pressing the button. When i leave the Button the STOP the LED blink.
2nd for loop not working any time. That's why i am very very upset and full of frustration on my project.
This is my code:
I've also attached the Circuit Diagram, MikroC PRO file and Proteus Professional simulation file. Please give me some solution about my project.
Please help help help ......................
I am new in micro-controller programming and starting a new project on 4 LED blinking using MikroC PRO for PIC v5.6.1. I choose PIC-16F877A for this project.
I want to blink the 4 LED sequentially (24 times clock-wise and another 24 times anti clock-wise) when the Push Button is pressed.
I also used Proteus Professional for checking my program. I see that my code is working good in Proteus Professional.
No problem arise when the .hex code is burnt on the PIC16F877A. Burn successfully!
But a problem arise when the push button is pressed. 4 LED blink sequentially (first for loop infinitely) but need still pressing the button. When i leave the Button the STOP the LED blink.
2nd for loop not working any time. That's why i am very very upset and full of frustration on my project.
This is my code:
Rich (BB code):
void main(){
TRISA = 0b11111111;
TRISB = 0b00000000;
PORTB = 0b00000000;
CMCON = 7;
ADCON1 = 7;
// Turn ON/OFF LEDs on PORTB
while(1)
{
int i,j;
if(PORTA.F0 == 0)
{
for(i=1; i<7; i++)
{
PORTB.F1=1; //(1st LED) or 34 No. PIN is ON
Delay_ms(500);
PORTB.F1=0;
PORTB.F2=1; //(2nd LED) or 35 No. PIN is ON
Delay_ms(500);
PORTB.F2=0;
PORTB.F4=1; //(3rd LED) or 37 No. PIN is ON
Delay_ms(500);
PORTB.F4=0;
PORTB.F5=1; //(4th LED) or 38 No. PIN is ON
Delay_ms(500);
PORTB.F5=0;
}
for(j=1; j<7; j++)
{
PORTB.F4=1; //(3rd LED) or 37 No. PIN is ON
Delay_ms(500);
PORTB.F4=0;
PORTB.F2=1; //(2nd LED) or 35 No. PIN is ON
Delay_ms(500);
PORTB.F2=0;
PORTB.F1=1; //(1st LED) or 34 No. PIN is ON
Delay_ms(500);
PORTB.F1=0;
PORTB.F5=1; //(4th LED) or 38 No. PIN is ON
Delay_ms(500);
PORTB.F5=0;
}
}
}
}
I've also attached the Circuit Diagram, MikroC PRO file and Proteus Professional simulation file. Please give me some solution about my project.
Please help help help ......................
Attachments
-
138 KB Views: 217
-
113.8 KB Views: 411
-
104.2 KB Views: 149