The railway link is shocking to me. All this time I thought train gates and indicators were already automated. Is it actually true that this process is still manual? A guy has to go and push a button as a train appoaches a crossing and must be actually told by the train driver "I am approaching"? Seems beyond reason to me, I don't know.
Take a look at a IR-Module datasheet:
**broken link removed**
Starting simple. Try to understand line of sight light detection or interruption. The light receiver will put out relatively constant voltage level given the light source is constant. When the light beam is interrupted, the receiver responds by changing its output voltage level. Change can be either increase or descrease in voltage, the change is whats important. So then the 8051 detects the change and does its job.
On to specifics. Visible light detectors do not function properly in a visible light environment. So Infra-red light is employed for its low ambient level to transmission level ratio. This same railway gate control could use constant IR transmission without need of the 555 timer. So why use pulsating IR? Pulsating IR can be filtered, which gives the advantage of suppressing false interrupts like naturally varying ambient light levels. IR-Receiver modules are good for suppressing false transient interruptions and they auto adjust to changes in ambient light. The IR-Emitter is driven by a 555 at 38KHZ to satisfy the 38KHZ requirement of the IR-Receiver module. This 8051 design is taking advantage of the suppression feature of the IR-module. It will reject a constant 38KHZ signal. So now when a train passes between the line of site sensors (emitter-to-receiver) that constant 38KHZ signal is momentarily interrupted. The interruption forces the IR-module to come out of rejection mode and sends a pulse to the 555 then 555 sends pulse to 8051 chip.
Brevity. The BC548 transistor cause the IR Led to glow. BC548 pulsates at 38KHZ because its base is driver by a 38KHZ generator, 555. The 555 timer signal is governed by its 10K, 10K, .001uF little buddies.