Let's Make Robots!

Arduino and servo 360 degrees, help me please...

Hello friends!
I look for example code for Ardunio and a 360 ° servo for studying.
Who can help?

With thanking greetings


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

this is my test-code :

/* ========================================================================== */
/*                                                                            */
/*   servo360_2x.c                                                               */
/*   (c) 2012 Gerhard Hinze                                                         */
/*                                                                            */
/*   Description                                                              */
/*                                                                            */
/* ========================================================================== */

#include <Servo.h>
Servo leftmotor;
Servo rightmotor;
int pwmL,pwmR;

void setup()
leftmotor.attach(9); // af-motorshield servo 2
rightmotor.attach(10); // af-motorshield servo 1

void loop()
leftmotor.write(pwmL + 90); //  for use with continuous motor
rightmotor.write(pwmR +90);

Yes many thanks loves friends! As soon as I have time will I try it. I only still want to change the supply so that it opens with the servo

With best greetings and gratitude




PS: It is a servo shifting continuously

If its only 360 and not continues, just have a look at the map command. It can help you get from 0-360 and over to 0-1023 for the servo position.
If its only 360 and not continues, just have a look at the map command. It can help you get from 0-360 and over to 0-1023 for the servo position.

#include <Servo.h> #include "WProgram.h" class servo360 { private: uint8_t pin; uint8_t low, mid, high; int8_t spd; Servo S; public: servo360(void); void attach(uint8_t _pin); void tune(uint8_t _low, uint8_t _mid, uint8_t _high); void write(int8_t newSpd); }; servo360::servo360(void) { spd = 0; low=0, mid=90, high=180; } void servo360::attach(uint8_t _pin) { pin = _pin; } // Use this if the servo midpoint is not at 90deg void servo360::tune(uint8_t _low, uint8_t _mid, uint8_t _high) { low = _low; mid = _mid; high = _high; } void servo360::write(int8_t newSpd) { if (newSpd == spd) return; if (spd == 0) S.attach(pin); spd = newSpd; if (spd == 0) { S.detach(); return; } uint8_t u; if (spd < 0) u = map(spd, -100, 0, low, mid); else u = map(spd, 0, 100, mid, high); S.write(u); } servo360 s; void setup() { Serial.begin(9600); s.attach(9); s.tune(0,80,180); Serial.println("READY!"); } void loop() { static int8_t x=0; if (!Serial.available()) return; switch (Serial.read()) { case 'a': x--;break; case 's': x++;break; } s.write(x); Serial.print("x:"); Serial.print(x); }

I played with a couple of continuous rotation servos some time ago. The servos I used had a screw in the side of the servo to adjust the "0" position. http://www.bajdi.com/continuous-rotation-servos-and-arduino/

some fancy converted CR servos that kept the pot, but, moved it to allow for continuous adjustment after the conversion. I have seen a similar suggestion when converting servos, but, instead of a relocated pot they slotted the top of the pot and allowed for adjustment after the conversion also. I believe the slotted pot also required the shaft to be ground down, or the gear to be opened up to allow for the gear to freely rotate without adjusting the pot.

Thanks I will try and report ...


You will use the same servo commands as you normally would. You will have your #include<Servo.h>, Servo myServo and myServo.attach(pin).

In theory, if you send your servo a "centered" command (myServo.write(90)) it should stop. A number above 90 will make it go forward and a number below 90 will make it go in reverse. As these numbers move away from 90, the servo should move faster in that direction.

Now, in reality, that "centered" (off) position will rarely be 90. As a matter of fact, it can even change based on the temperature. There is no good way to do this, you just have to play around with your particular servo(s) and find their partcular center point. Your left servo might stop at 87 and your right servo might stop at 92. Just make note of these numbers where ever you keep your notes, change the numbers in your code and you should be all set.