double loop

Hello to everyone i have some problem with my last arduino sketch. In a few words in the main loop of my program i have to invoke a function and inside this function i should use another loop. Is this possible?? Can I use something like a loop?

thankyou very much

Yes, it’s called a “for loop”

for (i=0; i < 10 ; i++){
Serial.println(i);
delay(100); // a delay here so it doesn’t zoom by so fast in the monitor
}
This loop would start i at 0, then ++ add one until it violates the middle condition, so it will count up to nine.
You can put another for loop inside of that to do something else. Kind of like the movie Inception.

for

do - while

while

look at the reference

http://arduino.cc/en/Reference/HomePage

Loop()
{
int answer;
  for (int i=0; i<100; i++)
    {
      answer = f(i);
      Serial.println(answer);
    }
}

int sum(int j)
{
int s=0;
int x=0;
while (x < j) 
  {
    s += x;
    x++;
  }
return s;
}
Loop()

Where's the return type? Why are you defining another function whose name differs from a reserved name in case only?

      Serial.println(answer);

Some value appears on the serial monitor. What does it mean? Adding another Serial.print() statement with some descriptive text, to be printed in front of the value is generally a good idea.

answer = f(i);

Where's the f function?

int sum(int j)

This function isn't called anywhere. Why include it?

Aaaargh, typed too fast :-[ f() should be sum(), and Loop() should be void loop(void) without the captital L and void setup() is missing too

thanx Paul.