How can I stop the void loop function?

Hi there!
I'm doing a project and I got stuck, cause I'm reading a analog lecture with the analogRead() function, and depends of that lecture, I
got a servo attached to a PWM pin that move by the lecture, the deal is that, I just one that the servo move for one time, and as the lecture is continuously displaying the analogRead() my servo move as the same time that the lecture display, How can I tell it, that it has to move just one time? Is there any way to stop the void loop() ?

Thank u so much!

If you want to do something one time, do it in setup(), not in loop().

There is no such thing as a 'void loop' function. There is a loop function, and its return type is void. They're called "banks", not "cash banks."

Or, in my case, void banks :frowning:

You cannot stop void loop fn as it is infinite while fn with an argument which is always true.It's return type is void.

while(boolean=true)

somanshumehta:
while(boolean=true)

What? Why?

Need == there.

You can set a "flag', let the servo move one time if the flag is 0, and if the flag is 1 then don't let the servo move.

if (servoMoveFlag == 0){
// move the servo
(servo move code goes here)
// set the flag for next pass thru loop. don't move again unless something clears the flag
servoMoveFlag = 1;
}

Need == there

The outcome's the same :wink:

AWOL:

Need == there

The outcome's the same :wink:

error: expected primary-expression before '=' token

error: expected primary-expression before '==' token

Almost the same. XD

Only because that's a datatype name there, and not a variable name.

AWOL:
Only because that's a datatype name there, and not a variable name.

That was my point - I assumed it was also your point. The fragment posted that looked like code was complete nonsense.

Just keep trace of the previous analogread output. If the new one is the same as the previous (or close enough) do nothing, otherwise do your stuff.