Sorry about that. Here is the current code. Still no difference. I have even tried to change the delay values in the loop. Does anyone know if the servo.write function automatically refresh the servoe signal every 25 ms? Where can I find more documentation about that library other than on Arduino.cc?
Thanks, Tripacer
//Fuel Tank Control program version 2a : FuelTankControl2a.ino
// Input values come from external program. Values range from 0 to 100
// which represents the range of tanks values from empty to full.
// Values are sent in two byte pairs; left tank first followed by right tank.
#include <Servo.h>
Servo LeftTank; // Create a seervo object to control a servo
Servo RightTank;
int LeftTankVal;
int RightTankVal;
int LeftTankReadVal; // Converted int value
int RightTankReadVal;
int LeftTankMin = 30; // Left tank minimum value
int LeftTankMax = 125; // Left tank maximum value
int RightTankMin = 30; // Right tank minimum value
int RightTankMax = 125; // Right tank maximum value
char CommandVal; // Input command value
byte TankVal[2]; // Left and right tank input values
int LeftTankRange; // Left tank Min to Max servo movement range
int RightTankRange; // Range for right tank
int i; // Array index
void setup()
{
LeftTank.attach(8); // attach the servo to pin 9 to the servo object
RightTank.attach(9); // attach the servo to pin 10
// Set initial servo positions **** if possible in setup block ****
LeftTank.write(LeftTankMin);
RightTank.write(RightTankMin);
LeftTankRange = LeftTankMax - LeftTankMin; // Calculate range value
RightTankRange = RightTankMax - RightTankMin;
Serial.begin(9600); // Start and configure servial communications
}
void loop()
{
i = 0; // Initialize index counter and read both values
while (Serial.available() != 0 )
{
TankVal[i] = Serial.read();
i++;
}
// End data read loop
// This section zeros the value and converts byte value to int
LeftTankReadVal = 0;
LeftTankReadVal = LeftTankReadVal + TankVal[0];
RightTankReadVal = 0;
RightTankReadVal = RightTankReadVal + TankVal[1];
// Calculate servo positions
LeftTankVal = (LeftTankRange * LeftTankReadVal) / 100;
RightTankVal = (RightTankRange * RightTankReadVal) / 100;
// Move servo to new position
LeftTank.write(LeftTankVal);
delay(10);
RightTank.write(RightTankVal);
delay(10);
// delay(20); // waits 20ms between servocommands -
// Does Servo library automatically refresh the servo signal every 25ms?
} // end of program