Servo unnecessarily trying to reach an already reached angle.

In the code attached, I am trying to simply use two buttons on an IR remote to control the angle on a servo. That all works perfectly, but the problem lies when the servo does not stop trying to reach the angle specified(as it is obviously in a loop).

I am simple seeking a suggestion on an easy way to cut the power to the servo when it has already reached the desired angle… until the next button press. The servo makes a noise that sounds like it is struggling, and I don’t intend on using too much unnecessary power. Thanks!!

Servo_Controller.ino (682 Bytes)

UPDATE: Solved problem. Just had to detach the servo at the start of loop, and re attach it at the start of every if statement

Joshua10902:
UPDATE: Solved problem. Just had to detach the servo at the start of loop, and re attach it at the start of every if statement

There must be some other problem. It is not normally necessary to detach and re-attach servos.

How are you powering the servo? It should NOT be drawing power from the Arduino.

...R

Agreed. Power is worth checking.

If it is re-seeking, the variable that stores the servo position perhaps is being overwritten / reset or some other oddness. Is it declared static or global? That may be what it needs.

(not downloading ino code on my tablet - repost within code tags)