Search wiring.org.co:

This example is for Wiring version 1.0 build 0100+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.

DigitalReadSerial Reads a digital input pin 8, prints the result to the serial monitor Click on the serial monitor button to open it.

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

    void loop()
    {
      int sensorValue = digitalRead(8);
      Serial.println(sensorValue, DEC);
      delay(100);
    }