I set out to control a Parralax 360o continuous servo, so that I can control the speed and direction using a Pot. As a starting point I tried to use the standard Servo library for a 180o Servo and found I could control the servo, and by adjusting the output range to suit I can now control the servo adequately, clockwise, anticlockwise and stopped with 15 speeds in each direction. The code is below:
I now need to write a report explaining how I am doing this. What I want to know is if there is a document or guide explaining the output signal of the standard servo library.
I believe the Parralax 360o continuous servo works by PWM whereby a pulse width of 1500ms is the stop command which I can therefore attribute to the Centre/ 90o output from the servo library. 75o-105o from the servo library gives me the full range of speeds from the Parralax 360o continuous servo, essentially I need a way of finding out what the PWM values are for this range.
I suspect there is a correct method for doing this using the writeMicroseconds() command any enlightenment would be much appreciated.
#include <Servo.h> //include servo library
Servo Parralax; //create object Servo Parralax
int const potPin = A0; //create constant for the Pot. attached to A0
int potVal; //create Pot. Value variable
int servoVal; //create Servo Value variable
int dirSpd; //create Direction Speed variable
void setup() {
Parralax.attach(9); //tell Arduino that servo is attached to Digital Pin 9
Serial.begin(9600); //open the Serial interface
}
void loop() {
potVal = analogRead(potPin); //read the analog input A0 from the Pot.
Serial.print("Pot. Value: "); //print the Pot. Value via the Serial interface
Serial.print(potVal);
servoVal = map(potVal, 0, 1023, 75, 105); // map the Pot. Value to the Servo Output Value Range
dirSpd = (servoVal - 90); //calculate the Direction/Speed variable by subtracting 90 degrees
Serial.print(", Direction (+=AntiCW/-=CW), Spd (1=slow/15=fast): ");
Serial.println(dirSpd); //print the Direction and Speed Value via the Serial Interface
Parralax.write(servoVal); //send the required Direction and Speed Value to the Servo
delay(250); //wait 250ms before looping
}
