Go Down

Topic: SERVO HACKING FOR CONTINUOUS ROTATION PROGRAM CODE (Read 5576 times) previous topic - next topic



I believe this is not a new topic but recently i just came across to hack my servo so it can continuously turn 360 degree in clockwise and anticlockwise..

So this is how i hack my servo: http://todbot.com/blog/2009/04/11/tiny-servos-as-continuous-rotation-gearmotors/comment-page-1/#comments

After i hack my servo, i would like to write a program so it can turn in clockwise and anticlockwise when received signal from my transmitter. What i want is exactly from this video: http://www.youtube.com/watch?NR=1&v=ofMfJyc-xbs

Hope anyone whoever try this before can help me with the program!!! I really need it very very much!!! Thank you!!! :D


Please don't use capitals it is like shouting.

can help me with the program

By help do yo mean, by any chance, do it all for you, or do you actually mean help?


So you have hacked the servo by Taking out the pot and replacing it with a couple of resistors (and a trimpot to balance the two).

Coding would seem simple,  setting the servo position a value of plus degrees moves it forward (the more degrees the faster I guess) and to stop to set the position back to zero.
Reversing would me setting negative values.

ie: start +5, then faster +10 and stop -15.

That's my guess anyway.


Ya i replaced the potentiometer with resistor..

I try to write my program like this:

void clockwise (){
      deg += 1;
    if (deg >180) { deg = 180; }
void anticlockwise (){
      deg -= 1;
    if (deg <0) { deg =0; }

but it does not work...

I jus need someone who can tell me what to write in my loop program so i can control the servo direction... i will very appreciate it... thanks


Two points:-
1) It is now a continuous rotation so it doesn't matter what degrees it is.
2) You don't appear to be giving any servo control commands in that code.

You need to find what angle corresponds to off. Then just set the motor for an angle greater than this for clockwise or less than this for anti clockwise. The larger the difference between zero angle and the angle you give will determine the speed.


so u means i must use the servo.write() to determine the angle?


So you have read http://www.arduino.cc/en/Reference/Servo and looked at this http://arduino.cc/en/Tutorial/Sweep

I'm guessing if you set pos to a positive number it will spin forward
Code: [Select]

myservo.write(pos);  // start forward movement

delay(2000); // wait a couple of seconds

myservo.write(pos);  // stop forward movement  I think?

delay(2000); // wait a couple of seconds


so u means i must use the servo.write() to determine the angle?



Ok i gt it edi...

Really thank you for both of you... Appreciate it very much :)


so u means i must use the servo.write() to determine the angle?

No - servo.write is going to be more of a speed control (within limits). You removed the position feedback inside the servo to make it a continuous rotation. Ideally your dead spot should be at 90 and numbers less than 90 will rotate in one direction and numbers greater than 90 will rotate in the other direction. You could write some code that starts at 0 and goes to 180 and then back to 0 with a pause at each setting, write the current output value to the serial and then you can see where the servo starts and stops each direction and use an nuber in the mddle of where it stops from each direction as you zero speed number.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131