I want to print the time on the serial monitor at the start and end of a signal (Help)

My guess is the OP just wants to print when the signal level changes. OP needs to look for a change in the level and not the state of the level.