I am struggling to figure out software to make my project work and I would appriciate any help I can get please :o I am building a chicken door opener and closer.
I have a light sensor and a motor connected via the Arduino. I need to write code that allows me to continously monitor the light sensor and once the sensor hits a value, I need the motor to turn and when the light sensor drops a value I need the motor to do turn again.
I found code that allows me to continously monitor the light (in a loop) and move the motors clock and anti-clockwise but putting everything in the loop does not help.
I need to put the LDR sensor in the loop and it records the value of the sensor, but then when a value is triggered come out of the loop and turn the motor till the job is done and stop moving the motor, then go back into the loop till the next LDR value is hit and then come out of the loop turn the motor, stop the motor and go back into the loop. It is kind of a loop in a loop.
I am looking for an example of a loop in a loop program. Can someone please point out some examples?