I am nearly done with my project but since I had to use servoTimer2 instead of the normal servo library I had to use different things. I got my robot to turn left, right, and go forwards but since I am using something that turns the pwm into degrees I cannot go backwards. I just want to go the same speed as forward but I cannot due to the fact when i do the opposite of my normal forward function it just turns in a circle or really any other combination that doesn't go straight(90, 90, 45 and 45, 90 and 45.) but I have all the directions in my program except backwards which is an very important in terms of real life testing.
Here is my code going forwards(the delay doesn't matter I just kept it the same after I played with going left and right. )
Also, the 2 servos are continuous rotation servos from parallax.
// this sketch cycles three servos to 0, 90 and 180 degrees
#include <ServoTimer2.h> // the servo library
// define the pins for the servos
#define leftWpin 10
#define rightWpin 12
#define degreesToUS( _degrees) (_degrees * 6 + 900) // macro to convert degrees to microseconds
ServoTimer2 leftWheel; // declare variables for up to eight servos
ServoTimer2 rightWheel;
void setup() {
leftWheel.attach(rightWpin); // attach a pin to the servos and they will start pulsing
rightWheel.attach(leftWpin);
leftWheel.write(degreesToUS(90));
delay(950);
rightWheel.write(degreesToUS(90));
delay(950);
rightWheel.detach();
leftWheel.detach();
}
void loop()
{
}
[\code]