Yes. Also there is no need for the while (1) loop in your sketch. The void loop() funtion will keep repeating your code. That is why it's called loop. ;D
Be aware that at 9600 baud your serial communication takes ~1 millisec per character send. If your pulses are faster than that you will miss them so set the baudrate at highest value possible e.g. 115200 is approx 10 times as fast.
below a variation on your code that holds the state and will only produce a timestamp + state if the value of the squarewave has changed.
(not tested)
int state = 0;
int value = 0;
void setup()
{
Serial.begin(115200);
Serial.println("Start");
pinMode(13, INPUT);
}
void loop()
{
value = digitalRead(13);
if (1 == value && 0 == state)
{
Serial.print(millis());
Serial.println (" one");
state = 1;
}
if (0 == value && 1 == state)
{
Serial.print(millis());
Serial.println (" zero");
state = 0;
}
}
If you can use another pin iso 13 you could use the led of pin 13 to show the state of the square wave too.