// myAutomation.h for simple ROUTEs with pin turnouts/points and signals directly connected to the Mega2560.
// Define our aliases:
ALIAS(TRN1, 100)
ALIAS(TRN2, 101)
ALIAS(SIG1_TRN1_APP, 30)
ALIAS(SIG2_TRN2_GO, 33)
ALIAS(SIG3_STN_EX, 36)
// Define our objects:
PIN_TURNOUT(TRN1, 22, "Station entry")
PIN_TURNOUT(TRN2, 23, "Station exit")
SIGNAL(SIG1_TRN1_APP, 31, 32)
SIGNAL(SIG2_TRN2_GO, 34, 35)
SIGNAL(SIG3_STN_EX, 37, 38)
// Start up with turnouts/points closed and signals red
CLOSE(TRN1)
CLOSE(TRN2)
RED(SIG1_TRN1_APP)
RED(SIG2_TRN2_GO)
RED(SIG3_STN_EX)
// We need DONE to tell EX-RAIL not to automatically proceed beyond definitions above
DONE
// Define our ROUTEs:
ROUTE(1, "Main track") // Select this route to just use the main track
RED(SIG3_STN_EX) // Set signal 3 red as it is not safe to exit the station siding
IFTHROWN(TRN1) // If turnout/point 1 is thrown, do these:
AMBER(SIG1_TRN1_APP) // Set signal 1 amber for 2 seconds to warn of the change
DELAY(2000)
RED(SIG1_TRN1_APP) // Set signal 1 red while we close turnout/point 1
CLOSE(TRN1) // Close turnout/point 1
DELAY(2000) // Wait 2 seconds for the turnout/point to close
ENDIF
IFTHROWN(TRN2) // If turnout/point 2 is thrown, do these:
AMBER(SIG2_TRN2_GO) // Set signal 2 amber for 2 seconds to warn of the change
DELAY(2000)
RED(SIG2_TRN2_GO) // Set signal 2 red while we close turnout/point 2
CLOSE(TRN2) // Close turnout/point 2
DELAY(2000) // Wait 2 seconds for the turnout/point to close
ENDIF
GREEN(SIG1_TRN1_APP) // Set signal 1 green because we're safe to proceed
GREEN(SIG2_TRN2_GO) // Set signal 2 green because we're safe to proceed
DONE
ROUTE(2, "Station siding") // Select this route to use the station siding
RED(SIG2_TRN2_GO) // Set signal 2 red as it is not safe to proceed beyond turnout/point 2 on the main track
IFCLOSED(TRN1) // If turnout/point 1 is closed, do these:
AMBER(SIG1_TRN1_APP) // Set signal 1 amber for 2 seconds to warn of the change
DELAY(2000)
RED(SIG1_TRN1_APP) // Set signal 1 red while we throw turnout/point 1
THROW(TRN1) // Throw turnout/point 1
DELAY(2000) // Wait 2 seconds for the turnout/point to throw
ENDIF
IFCLOSED(TRN2) // If turnout/point 2 is closed, do these:
AMBER(SIG3_STN_EX) // Set signal 2 amber for 2 seconds to warn of the change
DELAY(2000)
RED(SIG3_STN_EX) // Set signal 2 red while we throw turnout/point 2
THROW(TRN2) // Throw turnout/point 2
DELAY(2000) // Wait 2 seconds for the turnout/point to throw
ENDIF
GREEN(SIG1_TRN1_APP) // Set signal 1 green because we're safe to proceed
GREEN(SIG3_STN_EX) // Set signal 2 green because we're safe to proceed
DONE