why INPUT detects HIGH/LOW without power ?


hello,
 it appears when digital pin set input mode detects high/low without additional +5v applied. right or i'm seeing things? , true, why?

sketch:
code: [select]


int pin9 = 9 ;

void setup() {
  // put setup code here, run once:
serial.begin(9600);
pinmode(pin9,input_pullup);
}

void loop() {
  // put main code here, run repeatedly:
serial.println(digitalread(pin9));
delay(1000);
}


the schema :
pin9 -> j27
f27 -resistor(200om) -i18
h18 -push button - h16
j16- "-" rail -gnd on uno.

output - when button pushed - "1", when button not pushed "0".

when pin set input must pulled high or low external source before makes sense read pin.

whatever have connected pin not forcing pin high or low in consistent fashion. if have nothing connected pin, behavior seeing understandable.

use input_pullup ensure pin in known state nothing connected.


Arduino Forum > Using Arduino > Programming Questions > why INPUT detects HIGH/LOW without power ?


arduino

Comments