digitalWrite (pin, HIGH) ;
You mustn't let an input "float" (open-circuit) if you want a defined input value, input pins have effectively infinite resistanceand will sense ambient electronic noise quite happily.So you never connect just a switch to a pin, you always have a resistor pulling one way and a switch the other. Fortunatelyall Arduino pins have built-in pull-up resistors (about 30k ohms) that can be activated by callingCode: [Select] digitalWrite (pin, HIGH) ;when the pin is an INPUT (this is specific to AVR microcontrollers such as in the Uno and Mega).Or you can use an external resistor (which can be wired to pull-up or pull-down).
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16