Servo actuated with two switch, left - middle - right

Hi

I need to start from center position and then turn my servo from center position to turn left when switch 1 on closed. Then when switch 1 is open, back to middle. When switch 2 is closed, turn right, and again when switch 2 is open, in to the middle. Switches will not operate at the same time. This is a project to my boat setting gear to forward - idle - reverse, instead of mechanical lever and add remote control too.

I found this post (Servo actuated w/switch open and closed) very helpful, but dont get, how to ad switch 2 to operate the same servo…

Hello, timori.

Probably the easiest way to do something like that would be two IF/ELSE statements chained together. For example, the first one could check switch one and move the servo to the left if it is closed:

1 get_position 500 less_than if
	#move servo to left

If switch one is open, check switch 2, and move the servo to the right if it is closed:

  else 2 get_position 500 less_than if
    # move servo to right

If switch 2 is open, that means that both switches are open, so you can set the servo to the center:

  else 
    #move servo to center
  endif
endif

Brandon

1 Like