Ok..this might sound silly but i have a serious problem..i am trying to connect a simple switch to AT89s51 and once connected the switch ..the switch works perfectly fine ..but if i TOUCH the pin to which the switch is connected OR touch a piece of wire to ..say P2.0...it is actuated...i.e a low is detected in the programming...how can i avoid it..i.e the touch should not give a low unless it is actually grounded..
Try lowering the resistor. 1K or 470?. (1/4watt resistors)
The lower the resistor is the less sensitive it is to noise.
Touching directly a pin is much more sensitve then thouching the wire.
Also try the capacitor as mentioned before.
i think you know to set the pin to 1 , then try to reading
you can simple wire the button on P3.2 or P3.3 /int0; int1/ and make a simple interrupt with led