Our local model railroad club had a collection of mismatched detectors, signal PCB's, a sound card, and of course the masts for each side of the track with LEDs for indicators.
We utilize an Arduino UNO to read the state of two optical detectors, generate a START pulse when occupancy is first detected, as well as a latched relay output to energize the sound card. If after 3 seconds there has been no activity at either detector, a STOP pulse is generated, and the latched relay released, turning off the sound.
Subroutines for the input debouncing, and START and STOP pulses make the main loop and hopefully the whole program much easier to follow. I've also removed most of the commenting from the debounce subroutines. They are based on the example debounce sketch and I refer you there for more detailed commenting.
Comments