Hello, I am doing a project in which a set of servos turn a solar panel so that it finds the brightest spot. I have already written code and built the device that does this. When the device if first turned on it utilizes both servo motors to search the entire upper hemisphere of its environment and then takes in information about the brightness while also recording the coordinates of both servo motors that belong to the brightest spot. I am trying to implement a solar-tracking system so that after the unit has found the brightest spot it will scan plus/minus 20 degrees every 15 min to make sure that the sun hasn't moved too much. Like i said, i am able to find the brightest spot, but when i try to write the servo to a position relative to the variable that has the value of the brightest spot it won't work.
For instance, if the brightest spot is at 65 degrees, and the variable that holds the value 65 is "highestValueX", shouldn't i be able to say...
...say highestValueX is already at the value of 60...
for(int pos = (highestValueX - 20); pos < (highestValueX + 20); pos += 2)
{
myServo_X.write(pos);
delay(500);
}
Does anyone have any idea why this won't work? The servo either freaks out completely or will write to the positions below the highestValueX, but not the ones above it. Any help or suggestions would be greatly appreciated.