You need to set your pins to outputs with the pinMode command before using digitalWrite: http://arduino.cc/en/Tutorial/DigitalPins
And I'm not sure if you can use digitalRead to read the state of a pin set as an output.
EDIT: apparently you can... digitalRead will return the state that you set with digitalWrite.