Moving a servo with 2 separate buttons. Little question

Hello everyone! I’m new in the robotics world and I just bought a Pololu 6-channel servo controller and I need it for my school robot project. Basically what I’m trying to do is to control my servo with 2 separate buttons, button 1 for left rotation and button 2 for right rotation when the servo can do 90degrees in total. There is an explanation on this site how to connect one button but I understand it will work only in one direction, am I right? What about the other direction and how to connect it with the controller board to toggle movement with two buttons? I know it can be done on Arduino but I didn’t found any explanation on how to do this on Pololu.
It’d be great If you could help or just give me directions where to look. Thank you:)

Hello.

I moved your post to the Pololu Servos and Servo Controllers section of the forum.

As far as using multiple buttons, I am not sure what you mean when you say that it will only work in one direction. Do you mean that the button will only make the servo turn in one direction? You can control how the servo reacts to the button by writing a script. You might try looking at the “Using multiple buttons or switches to control servos” heading under the “Example Scripts” section of the Maestro user’s guide; it should give you a good starting place. If you try to write your own script and run into any problems, you can post what you have so far, and I would be happy to help.

If you need help connecting the buttons, the instructions in the “Attaching Servos and Peripherals” section of the user’s guide can be used to attach one button. The same method can be used to attach another button to a different channel on the Maestro.

-Brandon

I meant how does the controller know which direction it has to go when I press each button. The script shows how to use multiple buttons but it’s still one button to one servo I think. It’s simple when you have one button to rotate right and second to rotate left but when I connect two buttons to one servo it wouldn’t know which I’m pressing. Wouldn’t it be easier to use potentiometer, change to “Input” mode in control center to rotate the servo to the position I want without scripting, is it even possible to do it that way? Can I connect one potentiometer to each servo in paralel circuit and does every one of them has to be >1kOhm?

The “Using an analog input to control servos” section of the scripts page has a good example of how to make a script that takes a potentiometer input and translates that into a servo output.

As far as “Can I connect one potentiometer to each servo in parallel” The servos don’t get an analog voltage input. Each servo gets a pulse width modulated (PWM) signal, so you need some electronics in between the pot and the servo to do the translation.

It sounds to me like you want something that is almost exactly like the “Using multiple buttons or switches to control servos” example. It shows using 3 different buttons to run 3 different sets of commands. You would just modify your version so that button_a goes one way and button_b goes the other. In the code below both buttons move servo 3, they just move it to different positions:

sub sequence_a
  4000 3 servo 
  return
   
sub sequence_b
  8000 3 servo 
  return