const int BUTTON      = 8;

void setup() {
  pinMode(BUTTON, INPUT);

void loop() {



I have connected a cable to pin 8. It's not connected to anything else nor have I any other cables connected. I am expecting constant zeros, but I keep getting ones and zeros all the time, e.g. when shortly touching the cable.

I didn't experience that before. Did I accidentally damage my Arduino?

  • Why are you expecting constant zeros? Do you have a pulldown on the pin? Unconnected inputs are undefined, unless something is driving the pin it'll float around at random. A person is a good 50/60 Hz antenna and so when you touch the wire you'll get random noise. – Andrew May 31 '17 at 13:02
  • Google the phrase "Floating Input" – Majenko May 31 '17 at 13:08

If you don't connect it to anything, it can be a result of a flipping 'input' ... try to use a pullup or pulldown resistor.

Or better:


Use something like:


The pin is floating. Use pull up or pull down to help define its logic state.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.