First, the program should start when power supply first occurs or when it re-occurs, eg automatic program initialisation when the 5 volt power supply first rises above 4.75 volts.
The program operates in two mutually exclusive modes, namely a communications (COMMS) mode and a counting/timing (C/T) mode.