How to monitor the output using Adruino 328

I've got several problem here :

1 - How to send the pulses that generated by the quadrature encoder to my Adruino Duemilanove 328? My input should be like this

and this is my program in order to get the desire output

int value = 0;

void setup()
{
Serial.begin(9600);
  pinMode(13, INPUT);
}

void loop()
{
while (1)
{
{
  if (!(digitalRead(13)))
  {

  Serial.println ("one");
  
  
  }
  else
  
  Serial.println ("zero");
}
}
}

and after I've done compiling and uploading the program, can I just monitor the output using serial monitor that already have in Adruino Environment?

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

Lefty

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.