Pull-up Resistors

Also known as voltage dividers. When using the Arduino or Arduino LilyPad to read a digital or analog input you need to use a pull-up resistor or voltage divider to connect your sensor input pin to HIGH (= plus = positive = +5V), so that it is not “floating” and susceptible to noise.

External

You can connect a physical resistor between your sensor input pin and the positive connection as shown in the picture bellow

Internal

You can also include the following line of code in your void setup(){} function to set the internal pull-up resistors that are inside the microcontroller.

digitalWrite(#, HIGH);

# = the digital number of the pin that your sensor or switch is connected to!
this means that if you are reading an analog input, you need to use the digital number of the pin to set the pull-up resistor. For example, if you have your analog sensor connected to analog pin A2, then you will want to set your internal pull-up resistor with the following line of code:

digitalWrite(<strong>16</strong>, HIGH);

Matt explains pull-up resistors:

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Spam protection by WP Captcha-Free