2

Folks, I am a beginner to Arduino. I have a sketch that tests a set of INPUTS for HIGH or LOW by using a 'for' loop. When the for loop reaches an INPUT which is kept OPEN (no wires connected to it), the for loop apparently 'skips' that INPUT and move on to the next. However, if I have +5V connected to any INPUTS within the range of the for loop, it works correctly. Any thoughts what's is happening here?

2
  • 2
    probably bad programming ... the arduino will do exactly what you tell it to do, so you are giving it incorrect instructions
    – jsotola
    Dec 1 '20 at 1:54
  • You can edit your code into the question if you want to try for a more a specific answer.
    – timemage
    Dec 1 '20 at 16:56
2

You should always connect something to an input to pull it high or low when no signal is present. The simplest thing is to activate the built-in pullup resistor, which will result in the input returning HIGH when there is nothing connected. If that's not compatible with your particular use, add a resistor from the input to ground (10k-100k is fine) so that it will return LOW when nothing else is connected. If the input is just floating, it is susceptible to noise causing random state changes. The input impedance is very high (100 Meg) so it can pick up static and other mischief.

1
  • Thanks a lot. I'll avoid floating inputs.
    – Ranjith
    Dec 1 '20 at 4:01

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.