added volatile to the digitalRead statement