I am working on a project to make a servo spin when light level is high, and spin the opposite way when light level is low. However, I am having a few difficulties figuring out the language to do this. Any help is greatly appreciated! Thank you!
However, I am having a few difficulties figuring out the language to do this.
There are two parts to your problem. Determining the light level and moving the servo. Assuming that you have the photoresistor connected correctly, using a voltage divider, use analogRead() to read the light value.
Is an if test to see if the value is above or below a threshold (the value depends on the range of values you get in darkness and bright sunlight).
Once you know if the value is above or below the threshold, you can write a value to the servo to control its direction.