Need quick help with format

I need to know how to break a loop at the end of an if statement. My code looks something like this:

void loop(){
   // other code

How would i make the loop break once the other code is finished? I keep getting a "break statement not within loop or switch" error. This is probably an easy fix but I'm a beginner and I don't know what to do.

If you want to finish this iteration of loop(), just use a return statement. Loop will get called again by the main (hidden) function, but this iteration will be done. The return statement can be inside your if() statement if you need it there.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.