Hello,
I'm trying to make a solar tracker using an Arduino UNO and 2 servos.
To do so, im reading the values of two light sensors and comparing their values. When it's below a certain value, i want for the servo that is needed to move to move.
For example :
So, with this while, i want the servo to move in the direction of CHD, and to stop when CHD-CHG > 2, but if i do that i have to control the servo's speed, since i dont care about its position. However, i dont know how to control the servos speed.
Most standard servos operate on position, not time.
One could, I imagine, run the servo a given amount of time which may/may not work as expected against any distance parameters.
You are contradicting yourself. Moving the servo in the direction of CHD until CHD-CHG>2 is controlling the servo's position. The only effect of the speed of the servo is in how long it takes to travel from its current position to the position where CHD-CHG>2.
Even if you are using a continuous rotation servo, the light sensors are acting as positional feedback. You would need to control the speed of the servo in that case, but mainly to prevent overshooting the final position by so much that it takes forever to settle down and stop.
I think this problem is best solved by using a stepping motor rather than a servo. This is because the speed of movement is known and so you would not need any sensors.
By using sensors like you propose then it would not work if it is a cloudy day.
Until the op replies we can't do much.
I think that the op may be over thinking the situation and may need to experiment with the hardware. @danviouuu have you looked at other Arduino Solar Tracker projects, Google..
Can you please tell us your electronics, programming, arduino, hardware experience?
You will have to include some hysteresis in your code to stop the tracker hunting around the sweet spot.