I have the servos wired up according to this manual:
RobotShop Rover Development Platform
robotshop.com/content/PDF/robotshop-rover-development-manual.pdf
The yellow wire from servo is going into pin TX9. Red and Black wires from servo are going to breadboard and sharing the line with same as power for track pololu motors. Power to breadboard is setup with one line for ground and one for +. On breadboard first line (top right in picture): V+ coming in from battery, motor controller pin VMOT. The second line on breadboard has V- from battery, GND pin from pololu motor controller and the black wire from the servo controller.
A video showing the results in case it helps debug:
youtu.be/8BpXHBFffq4
Code:
[code]int servopulse1 = 1250; //test servo tilt position (0deg =0 to 180deg =1500)
int servopulse2 = 1500; //test servo pan position (0deg =0 to 180deg =1500)
int servopin1 = 9; //yellow wire from servo 1 to digital pin 9
int motor_reset = 2; //digital pin 2 assigned to motor reset
void setup()
{
pinMode(servopin1, OUTPUT);
pinMode(motor_reset, OUTPUT);
Serial.begin(9600);
digitalWrite(motor_reset, LOW);
delay(50);
digitalWrite(motor_reset, HIGH);
delay(50);
}
void loop()
{
servoposition();
delay(20);
digitalWrite(servopin1, LOW);
motorforward();
delay(2000);
motorstop();
delay(2000);
}
//subroutine servoposition
void servoposition()
{
for(int i=1; i<=20; i++) // Ensures the servos reach their final position
{
digitalWrite(servopin1, HIGH); // Turn the L motor on
delayMicroseconds(servopulse1); // Length of the pulse sets the motor position
digitalWrite(servopin1, LOW); // Turn the L motor off
delay(20);
}
}
//subroutine motor forward
void motorforward()
{
//left motor
unsigned char buff1[4];
buff1[0]=0x80; //start byte - do not change
buff1[1]=0x00; //Device type byte
buff1[2]=0x01; //Motor number and direction byte; motor one =00,01
buff1[3]=0x45; //Motor speed “0 to 128” (ex 100 is 64 in hex)
Serial.write(buff1, 4);
//right motor
unsigned char buff2[4];
buff2[0]=0x80; //start byte - do not change
buff2[1]=0x00; //Device type byte
buff2[2]=0x03; //Motor number and direction byte; motor two=02,03
buff2[3]=0x45; //Motor speed “0 to 128” (ex 100 is 64 in hex)
Serial.write(buff2, 4);
}
//Motor all stop
void motorstop()
{
digitalWrite(motor_reset, LOW);
delay(50);
digitalWrite(motor_reset, HIGH);
delay(50);
}
[/code]
As you can see the motor forward and motorstop() functions are working fine. Servo is not responding at all. Please help…