Please Help: LDR sensor and Limit swicth

Hello to everyone,
Please help someone ...
I'm trying to make a system that automatically opens and closes the chicken coop door with arduino.
I'm tired of getting up early in the morning :o :slight_smile: .

parts I use for the system; L298N motor driver, LDR light sensor, arduino uno and two pieces limit swicth, DC 12 Volt motor

the system should work as follows; When waiting for the LDR sensor when the sun is born, the door will be opened after waiting a bit when the required light is received. In the evening, when the light level falls from the opposite LDR, the door will be closed after waiting a little while the door will close and the limit swicth will stop the engine again.

but in my coding, the LDR sensor runs the engine, but the limit swicth signal doesn't stop the engine in any way ...

can you pst your code?

A schematic diagram of the project would help, too. See the how to use this forum-please read sticky to see how to properly post code and some hints on the information that will help us help you. See #7 & 11.

A huge amount of discussion on similar has taken place on these forums.

Did you search for these?

IMO, I would use a relay for motor control.

FYI

Or