Servo and Arduino

Hi Everyone,

I am working on a build where once a certain input voltage is reached, a servo gets triggered. I want it to work like I am pressing a button so it turns all the way.

I’ve tried a digital and analog write but the servo just sort of jitters and freaks out most of the time. Once in a while it will actually move but it seems random.

What is the right way to trigger a servo with an Arduino?

Thank you!!!

Hi @pghparkins,

This test program works. It turns the servo all the way after 10 seconds. (at i= 20)
Connect the servo to D5 output.
I used the USB power bit, the servo uses a lot of power so a battery drains quickly and then the servo goes haywire…
:grinning:

void setup() {
pinMode(5, OUTPUT);
digitalWrite (5,LOW);
}
void loop()
{
for(int i=0;i<255;i++)
{delay(500);
if (i==20){ digitalWrite(5,HIGH);}}
}

2 Likes

Hiya @pghparkins,

Since the voltage must be ‘fully on’ to activate the servo properly (as per @alexpikkert’s test program) you may wish to test the battery separately from moving the servo.

I’m not sure if you can do this directly with littleBits’ Arduino, but I will try it later this week when I get a chance to play with my set. It might require a proto bit with a diode attached across the middle (signal) line, so the Arduino doesn’t power the circuit under test.

2 Likes

Thank you VERY much for your help, you both provided key insights. I am using the slide dimmer + number bit on A0, and that seem to be what is throwing the servo for a loop.

I am trying to make a flux capacitor so that when the number bit shows 88 it would flash a light and flip the servo, which would then send a hot wheels delorian down a ramp.

I added a usb power bit to another input and then I have battery bit -> side dimmer -> number bit ->a0.

Much to my thrill, when that baby hit 88 miles per hour, the servo flipped as expected.

Now that the hardware and software is set, I just need to figure out how to attach the servo to my ramp mechanism, then build the flux capacitor box.

3 Likes

Back to the future ? nice… :grinning:

1 Like