stay in the same value of analog input give output one time

Keep track of the last value read and only print it when the value reaches 1023 and it wasn't 1023 on the last reading; This is known as signal edge detection.