if your pin is an analog pin, use the a/d mode to make a thresh-hold that works.......
(beat me by 2 minutes)