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

   }while (X = 2);

should be:

}while (X == 2);

Can you show your entire sketch please?