Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Help with switch for servos!


#1

Ok… So I need to know how to programme a switch to automate 2 servos. When I push a button once (not hold it on) I want both servos to move to a position and then push button again to return to original position.

I will also want to add a 3rd servo at a later date to move on the same button pushes.

Totally new at this… So no idea where to put the switch… Etc

HELP ME PLEASE!!!


#2

Hello.

You might consider using one of our Maestro USB Servo Controllers for that kind of application; you can find them here.

You can find information on how to use the Maestro to control your servos with a button, as well as instructions on how to wire the button to the Maestro, under the “Using a button or switch to control servos” subsection under the “Example Scripts” section of the Pololu Maestro Servo Controller User’s Guide.

-Robert


#3

I have one lol… sorry should have explained. I have the Micro Maestro 6-Channel USB Servo Controller (Assembled)

I have done a basic programme to mate servo 1 & 2 go from position a - b and back again, but I need to add a switch


Micro Maestro 6 Controller question
#4

Let me know if you have any questions.

-Robert


#5

Yeah I just really don’t understand how to write the script.

Also, how to I save a frame for the switch? Iv got it all wired up now. But can’t get it to do anything


#6

I am sorry you are having problems writing the script; you can copy the example script from the subsection in the user’s guide I referred to in my previous response here and paste it into the Script tab in the Maestro Control Center. After you are done pasting the example script, hit the “Apply Settings” button. Then you can click “Run script” to run the script.

In this case, the script does not use any user defined sequences, so you do not need to save any frames for the switch.

-Robert


#7

thanks, I tried this but got an error about the button. could really do with a step by step.

I have power supply, then servo on channel 5 and servo on channel 6. my button is on channel 1 and set to input. the slider does move from ‘255’ (or what ever number it is) to ‘0’ when I press the button, so I know its working. its just how to get the servos to respond when I push the button.


#8

the error I keep getting is always along the line of…

'error applying parameters. script:11:1: did not understand ‘wait_for_button_press’


#9

Are you sure you copied the entire script, including the definition of the wait_for_button_press subroutine? I recommend that you try getting the example script working first before you modify it. This means you will have to move your button to channel 0 and put one servo on channel 1.

-Robert


#10

how do I include the definition? I will try from the beginning though thanks.


#11

ok iv started from the beginning… and now its saying it cant find the main loop… or the button…


#12

ok… got it!!! finally lol… thanks for that. now for adding another servo on channel 2 to do the same movement at the same time as servo 1… while another servo on channel 3 does another movement… if that makes sense. not sure if it can be done??


#13

I am glad to hear that your script is working. It is possible to do that, but you would need to include a few extra lines in the “frame” subroutine to get your other servos moving. For example:

sub frame
  wait_for_button_press
  3 servo
  2 servo 
  1 servo
  return

You would also need to set the positions you want your other servos to move to under the “main_loop”. For example, the line:

will set all three servos to position “4000”. You could then modify that line to set one of your servos to a position different than the other two. Good luck!

-Robert


#14

I was about to try this, but when I come back to it and set everything back up to test it as just 1 servo, now when ever I press the button it disconnects from the programme and flashes a red light 4 times?!?!?!


#15

Hello. The Maestro user’s guide documents what a blinking LED at startup means:

[quote]When the Maestro is reset in some other way than being initially powered up, the red and/or yellow LEDs blink four times to indicate the reset condition:

  • Yellow off, red blinking: A brownout reset. This occurs when the Maestro’s 5 V line drops below about 3.0 V, usually due to low batteries or an inadequate power supply.[/quote]

This makes me think that you are having a power problem that only manifests itself when the servo draws a lot of current as it tries to move. If you are using batteries, please make sure they are freshly charged. Also, I bet you have your batteries connected to the Maestro’s VIN; it would help to disconnect VIN because then the Maestro’s processor can just be powered from USB.

If you continue to have trouble, please provide all the details about your setup, including pictures.

–David


#16

I need it to be powered without usb so it can be stand alone. also I have changed the battery to a 9v. the servo comes on an just keeps turning round in a 360 motion and will only stop when I disconnect the power.

I have the 9v powering the servo channels and also the processor. I cant figure out why it wont work because the setup hasn’t changed.


#17

I run the script, and it only disconnects an cuts off when I press the button.


#18

Unfortunately, powering servos with a 9V battery is not a good idea. Most servos are not built to tolerate voltages that high, and a 9V battery cannot provide the current needed to run motors. I strongly recommend that you switch to something better, such as four AA batteries. What were you using for power earlier?

Unless your servo is a continuous rotation servo, the behavior you describe makes it sound like the servo has probably been damaged.

–David


#19

I was using 3 as batterys. But was going to switch to 4. It needs to power 3 servos you see.


#20

ok so I added a second servo. im now using 4 x AA batteries powering the servo’s and the switch. could this be the reason that when I run the script and press the button it moves both servos a little but then disconnects from the programme?