I’m designing an arduino robot that’s objective is to find and drive towards a light using a photo resistor mounted on a servo. I want to write my program with PID control to sweep the photo-resistor while moving.
Currently my logic flow is:
- powerMotors(0)
- Continuously sweep servo 180
- Continuously collect photoresistor
- If photoresitor>photoresistorMax
- photoresistorMax = photoresistor
- Angle to light = servo position
- Error = 90 - angle to light
- powerMotors(Error*Kp)
So at the moment it is adjusted with P control. It wobbles and does not always make it precisely. I believe a major problem with it is that the sampling time essentially is limited by the time to sweep 180°.
Is there any adjustments you could recommend to improve sampling time and overall increase accuracy of my system?
Thanks