The 20M is a good chip, though without enough code space
Yeah. Tell me about it!
I had to do some pretty tricky code for that signalling system to get it to fit on the 20M, with about 2 bytes to spare. I'll be using a 40X2 for the main train detetction system for the level crossing with at least 12 LDRs connected. 3 tracks, bi directional. It's not just a matter of turning the gates/lights on when it detects a train, then turing them off 10 seconds later, (whether the train has fully gone past or not) like some of the "commercially" supplied ones do.
It's more complex than you may think. Have a think about it, how you would code it, to cater for all directions, with multiple trains, in either direction, on 3 tracks, entering and leaving the "detection zones" concurrently. I'm glad I've got the 4096 bytes of the 40X2, rather then the 256 bytes of the 20M.
For those that are "programming logic" minded, some things to think about.
1. You need to detect the entire train has left the detection zone.
2. The train may be longer than the detection zone
3. Another train may be following, and enter the detection zone before the one in front has left the detection zone.
4. An east bound train is not to trigger the west bound "detection zone" triggers.
....... and more.
then there's 3 tracks of this.
This one is going to take me a while to code and test and get it right.
The light flashing, gate raising/lowering bell ringing is already done. (manually tiggered), even to the extent that it will immediately begin lowering the gates again, (on being triggered) even if the gates are in the process of being raised.
Alan
TOOT!