Model Railroad Block Detection with Arduino.


Here we show how to secure a certain track section by signaling in which direction a train enters the section is occupied and if the block has been left again. 

Our model railroad block detection scenario.

In pseudo code the system works like this:

// enter the section from the left
if isFree(BC) then {
  if sensor(A) then {
    preOccupy(BC);
  }
  
} 
  enterSection("BC");
IF sectionStatusIsEntered("BC") AND enterTimeout("BC")
  releaseSection("BC");
IF readSensor(B) AND sectionStatusIsEntered("BC") THEN
    blockSection("BC");
,