c - How to break a loop in mikroC -
i primary in programming mikroc (microchip). need break loop in code have no result "break;" if me? need make after while condition satisfied "stop" everything!
this flowchart project:
here code:
void main() { int x=0; trisd=0b00011111; trisb=0b11111000; portb.f0=0; portb.f1=0; portb.f2=0; while(1){ if(x==3){break;} if(portd.f1==0) { if(portb.f2==0){portb.f1=1;delay_ms(50);portb.f0=1;delay_ms(300);portb.f2=1;} } if(portb.f2==1){portb.f0=0;} if(portd.f1==1) { portb.f1=0;portb.f0=0;portb.f2=0; } portb.f2=0; delay_ms(300); while(x<=4){ x++; if(portd.f1==0) { if(portb.f2==0){portb.f1=1;delay_ms(50);portb.f0=1;delay_ms(300);portb.f2=1;} } if(portb.f2==1){portb.f0=0;} if(portd.f1==1){delay_ms(300);portb.f0=0;portb.f1=0;portb.f2=0;} } } }
try with:
if(x>=3){break;} since increase x 5 here: while(x<=4){x++, , enter infinite loop.

Comments
Post a Comment