I/O input reading random

did you specify pinMode(pin, INPUT);