Hi, i'm using 16F877A microcontroller for rotating stepper motor. I also using C compiler and MPLAB IDE. My code is working good on Proteus Professional. But when i write on PIC, for loop is not working. Only one loop is working. It is noted that for checking output, i used 4 LED. When i press the button the 4 LED is ON sequentially(first loop) but the next loop is not working.
I'm new that's why can't understand why for loop is not working? This is my code.
#include<16F877A.h>
#fuses HS,NOWDT
#use delay(clock=10000000)
void main()
{
set_tris_a(0xFF);
set_tris_b(0x00);
port_b_pullups(TRUE);
output_b(0x00);
while(true){
if(input(PIN_A0)==0){
int i;
for(i=0; i<6; i++){
output_bit(PIN_B1,1); //34 No. PIN
delay_ms(500);
output_bit(PIN_B1,0);
output_bit(PIN_B2,1); //35 No. PIN
delay_ms(500);
output_bit(PIN_B2,0);
output_bit(PIN_B4,1); //37 No. PIN
delay_ms(500);
output_bit(PIN_B4,0);
output_bit(PIN_B5,1); //38 No. PIN
delay_ms(500);
output_bit(PIN_B5,0);
}
}
}
}
Please give me the solution why "for loop" is not working?
I'm new that's why can't understand why for loop is not working? This is my code.
#include<16F877A.h>
#fuses HS,NOWDT
#use delay(clock=10000000)
void main()
{
set_tris_a(0xFF);
set_tris_b(0x00);
port_b_pullups(TRUE);
output_b(0x00);
while(true){
if(input(PIN_A0)==0){
int i;
for(i=0; i<6; i++){
output_bit(PIN_B1,1); //34 No. PIN
delay_ms(500);
output_bit(PIN_B1,0);
output_bit(PIN_B2,1); //35 No. PIN
delay_ms(500);
output_bit(PIN_B2,0);
output_bit(PIN_B4,1); //37 No. PIN
delay_ms(500);
output_bit(PIN_B4,0);
output_bit(PIN_B5,1); //38 No. PIN
delay_ms(500);
output_bit(PIN_B5,0);
}
}
}
}
Please give me the solution why "for loop" is not working?