zoomkat:
No, I need the servo to rotate continuously (I already modified my servo). I tried putting 180, 360, 90, none of them works
http://www.instructables.com/id/Very-simple-clean-up-robot/%20for%20a%20school%20project
If you modified your servo for the usual continuous rotation, then it in itself cannot be commanded to a specific position. You might be able to use an encoder attached to the servo to determine when the servo should be commanded to stop rotating. If you modified the servos to be wheel drives for the bot, then you should have sent them a 1500us command and tweaked the pot until the servo motor stopped rotating, then glued the pot. Below is some servo test code you might use to determine the current servo command value at which the servo stops rotating. As usual this instructable is a lttle light on some important details, but is still a good project.
// zoomkat 3-28-14 serial servo incremental test code
// using serial monitor type a character (s to increase or a
// to decrease) and enter to change servo position
// (two hands required, one for letter entry and one for enter key)
// use strings like 90x or 1500x for new servo position
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually DOES NOT WORK.
#include<Servo.h>
String readString;
Servo myservo;
int pos=1500; //~neutral value for continous rotation servo
//int pos=90;
void setup()
{
myservo.attach(7, 400, 2600); //servo control pin, and range if desired
Serial.begin(9600);
Serial.println("serial servo incremental test code");
Serial.println("type a character (s to increase or a to decrease)");
Serial.println("and enter to change servo position");
Serial.println("use strings like 90x or 1500x for new servo position");
Serial.println();
}
void loop()
{
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
if(readString.indexOf('x') >0) {
pos = readString.toInt();
}
if(readString =="a"){
(pos=pos-1); //use larger numbers for larger increments
if(pos<0) (pos=0); //prevent negative number
}
if (readString =="s"){
(pos=pos+1);
}
if(pos >= 400) //determine servo write method
{
Serial.println(pos);
myservo.writeMicroseconds(pos);
}
else
{
Serial.println(pos);
myservo.write(pos);
}
}
readString=""; //empty for next input
}
I only modified my servo by cutting the mechanical stopper in the gear, without touching the potentiometer at all. I thought by only doing that it won't rotate but if I write the code like this:
servo.write(0);
it rotates, but the left side ccw and the right side cw. and I need all to rotate cw