The microcontroller takes care of all the de-bouncing and timing and switching functions which are usually handled by op amps and transistors. The resultant savings in parts allow the entire circuit to be constructed on a 1″ X 3″ circuit board
The circuit is quite simple. Figure 2 illustrates the “heart” of the block activity detection system. Two opto-isolators are connected across a 4 amp bridge rectifier which produces a voltage drop across it’s AC terminals when current is drawn in the block of track connected to it. A locomotive or wheelsets with a resistor connected across the wheels will draw the current to set the circuit off. The opto-isolators detect which direction the current is flowing in and send signals to the microcontroller. The microcontroller processes the input signals and turns on the corresponding indicator outputs. (For simplicity I have not shown all of the components required for this circuit. The lamp or LED driver is a ULN2003 IC which will sink up to 500ma per output.) When no activity is detected, the indicators extinguish. The block activity indicators turn off after a 1/2 second delay and the grade crossing lights or LEDs will turn off about 2 seconds later. All outputs are absolutely flicker free.
Visit Here for more.