turn led on/off and read state of pin