I'm looking for help with a fairly simple project. Using the servo library, I need to have a servomotor turn 180 degrees in one direction when photoresistor 1 receives light and to turn back to 0 when photoresistor 2 receives light. Also, if both photoresistors have light, the motor should rotate in the middle to 90.
That doesn't sound very difficult. There are several examples in the IDE that can help with using servos and LDRs.
So show us what components you are using, what code you have tried and tell us how it works. Then we can help.
int lightValue = analogRead(A0);
lightValue = map (lightValue, 0, 1023,0, 180);
Servomotor - 5v input, ground, digital pin 9
Photoresistor 1 5v input, Analog 0, resistor to ground
Photoresistor 2 5v input, Analog 1, resistor to ground
I have the fundamentals for a one photoresistor circuit, but need to adapt it to work on the second. Possibly with an if statement
You are on the right track.
Take the second step and add another analog.
You can do things like:
if( input1 > 100 && input2 > 100)
. . .
else if( input1 > 100 && input2 <= 100)
. . .