Modified servos. SOLVED!!

Im making a photovore and Im trying to make my servos spin both directions. They do spin both ways, but I cant make the code tell them to do that… Its supposed to be a value under 0-89 is backwards, 90 is stop and 91-180 is forewards. But when I try it, 1 and above is forewards and 0 is stop. How do I make it go backwards? DId I modify it wrong?

( I glued the potentiometer, not soldered resistors. And these are the servos I used)

And this is the simple code I wrote:
#include <Servo.h>

Servo leftservo; // create servo object to control a servo

void setup()

void loop()


Its supposed to be a value under 0-89 is backwards, 90 is stop and 91-180 is forewards.

So you coded this:


I guess that works.

leftservo.attach(8); // attaches the servo on pin 9 to the servo object

What pin do you have the servo connected to?

Haha I've been messing around with all sorts of numbers. It just says pin 9 because thats what was copied off the Arduino website (in the controlling a servo with a potentiometer.) Its definitally in the right pin. And ever number I tried only makes it go one way, but once I hit about 50 it doesnt seem to go any faster. Thats not a problem, Im probably only going to use +/- 15.

Do i need negative numbers? Or can i even do that?

If I remember correctly, Servo.write expects a value between 0 and 180. It moves the servo to that position.

If you have modified the servos to be continuous rotation gear-motors, you have to use the writeMicroseconds method with some value that makes it hold still, and smaller values to turn one way, and larger values to make it turn the other way.

Check the documentation for the Servo library.

I looked it up, and 1500 should be neutral, 1000 one way and 2000 the other. 0-500 is neutral, and 500+ is forewards....

Did I modify it wrong?

AHA! When I was told to send the signal to the servo to know where to glue the potentiometer, it said send it to neutral position. I sent it go to 0 position. So that means that anything above 0 is forewards and below 0 is backwards, right? So, If i redo it with 90 being neutral then it should work, correct?