Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for loop not executing
12-02-2019, 07:45 PM,
#1
for loop not executing
I am using V12 with a Pic18f2455 with XC8 compiler
The " for" loop does not  execute (I noticed the same thing in V11). 
the code is very simple :



void setup() {
// put your setup code here, to run once:
pinMode(USERLED, OUTPUT);

}


void loop()
{ int count;
for(count=0;count>=10;count++)
{toggle(USERLED);
delay(500);}


}
Reply
13-02-2019, 03:57 PM,
#2
RE: for loop not executing
That is correct.

You probably mean count <= 10

The code as it stands is working.

John
Reply
13-02-2019, 05:36 PM,
#3
RE: for loop not executing
 count <= 10      Exclamation

Thanks a lot such a rookie error.
claude
Reply
13-02-2019, 07:58 PM,
#4
RE: for loop not executing
Don't worry - we've all done something silly!

Thinking more, you may mean <10 rather than <=10

John
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)