Automatic Railway Crossing


My question is, can someone help me or if you want and have spare time, write the code?

There might be someone willing to write the code for you but it's unlikely.

There are a lot us willing to help you if you get stuck writing it yourself.

Start by breaking you projects into small parts on learn to control each of the individual parts of the project than add these various parts together.


Right, first things first.

Go and read the instructions, then go back and modify your post (use the “More → Modify” option to the bottom right of the post) to mark up the code as such so we can examine it conveniently and accurately.

If you pick the right pull-up resistor, you use digitalRead(), not analogRead().

You need your two LDRs to work independently, but you've connected them both to A0.
Instead, connect one to A0 and the other to A1 (or any other of the analog input pins).