servo motors 2 directions continous rotation

hi guys I've customized my servo motor to rotate continousely how can I make it rotate in two directions
clock and anticlockwise ??

Anouar47:
hi guys I've customized my servo motor to rotate continousely how can I make it rotate in two directions
clock and anticlockwise ??

At the same time?

of course not I just need the command line which can make t rotate clockwise and the the other command for the other anticlockwise rotatoin

It is a servo.
You include the servo library.
You instantiate a servo class.
You write values to the servo.

Do not power the servo from the arduino 5v pin. Use an external power source for the servo power.
But DO connect common ground between the battery and the arduino.

Have you looked at any of the servo tutorials? Google “servo sweep arduino” and I bet you will find many.

Anouar47:
hi guys I've customized my servo motor to rotate continousely how can I make it rotate in two directions
clock and anticlockwise ??

If you have set the internal pot in the correct position.
Using Servo library.
myservo.write(90); should be stop

myservo.write(90);
to
myservo.write(0); should be rotate one way, the closer to 0, the faster it goes.

myservo.write(90);
to
myservo.write(180); should be rotate the other way, the closer to 180, the faster it goes.

You may need to adjust the 90 as stop position.
Tom... :slight_smile:

guys I tried your suggestions but it didn't work may I add that my servo is an SG90

and it only rotates in one direction please any guidance would be great thank you all

Let’s see the code you tried it with and a diagram of how ir is connected to the Arduino and power supply.

When it rotates does it go through 360 (and more) degrees ? Does the rotation speed vary with the value written to it ?

The pins are 9 to data and ground and 5v of arduino

the servo rotates 360 degrees and speed does not change whatever is the servo.write value

testservomoteur.ino (291 Bytes)

The pins are 9 to data and ground and 5v of arduino

Do NOT connect the servo to the 5V of the Arduino.

may I add that my servo is an SG90

Without posting a link, no you may not.

the servo rotates 360 degrees and speed does not change whatever is the servo.write value

I am afraid that it sounds like you bodged the conversion to continuous rotation.

The problem is I run out of pins in my arduino and I cannot add a relay to command
do I have to remove the potentiometer wires becuse I didn't :slight_smile: :slight_smile: :slight_smile: :slight_smile: ?????

Seems like you have to replace the servo's position pot with 2 equal value resistors to bias the electronics to 1/2 power supply voltage, did you do that?

Nope I will do it thank you all for your help