Hi,
I am building a little tank that has two 360 degree servos for power and two potentiometers for control. I have two types of servos: one is a PowerHD AR-360HB robot servo, and the other one is a TowerPro MG90D 360 servo (see http://www.towerpro.com.tw/product/mg90d-2/).
When I connect them to the Arduino, the PowerHD response is fine: I can stop all rotation with the linear pot at the center, get full speed rotation clockwise at one end, and full speed counterclockwise at the other.
But the TowerPro doesn't act rationally at all: it starts very slow, then accelerates to top speed and returns to crawl, regardless of the potentiometer.
So my question is, does the TowerPro have to be coded some other way from the PowerHD?
This is the code (I am testing one servo at a time, but this code makes the PowerHD act as I
expected):
#include <Servo.h> // Include servo library
int servoRightPin=4;
int servoLeftPin=2;
Servo myServoLeft;
Servo myServoRight;
int speedLeft = 1485;
int speedRight = 1485;
void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
digitalWrite(A0, HIGH);
pinMode(A3, INPUT);
digitalWrite(A3, HIGH);
pinMode(servoRightPin, OUTPUT);
pinMode(servoLeftPin, OUTPUT);
myServoLeft.attach(2);
myServoRight.attach(4);
}
void loop() {
int sensorValueA = analogRead(A0);
int sensorValueB = analogRead(A3);
float voltageA = (sensorValueA * 1.75) +600;
float voltageB = (sensorValueB * 1.75) +600;
speedLeft = map(voltageA, 600, 2400, 1100, 1800);
speedRight = map(voltageB, 600, 2400, 1100, 1800);
Serial.print("speedLeft ");
Serial.println(speedLeft);
roll_left_servo(speedLeft);
delay(10);
}
void roll_left_servo (int rollspeed_left){
myServoLeft.writeMicroseconds(rollspeed_left);
delay (10);
}