Understanding The Pull Up Resistor With Arduino
Understanding The Pull Up Resistor With Arduino
by PanosA6
With this little test I hope you'll understand why the pull- int Led = 10;
up (and pull-down) resistors are needed in digital circuits
like in Arduino. void setup() {
pinMode(buttonPin,INPUT);
With a pull-up resistor and with the button unpressed pinMode(Led,OUTPUT);
you make a logic state ON and with the button pressed Serial.begin(9600);
you make a logic OFF. }
With a pull - down resistor and a pressed button you void loop() {
make an ON logic state and OFF logic state when its int buttonState = digitalRead(buttonPin); //read the
unpressed. state of the button input
if (buttonState == LOW) { // if the button is pressed it is
Make the above pull-up circuit and try the code. You'll low state
see the LED ickering or less bright. digitalWrite(Led,HIGH); //see ickering led or less bright
Pressing the button and you see now the LED turned } else {
normaly on (fully bright). Turning o the button and the digitalWrite(Led,LOW);
LED its ickering again. Serial.println(buttonState);
}
/*Pull-up resistor test*/ }
int buttonPin = 3;
On the left you see the button the moment its beeing pressed. This gives a digital signal of the LOW state.
On the right the voltage across the pull-up resistor with the button unpressed is 5Vdc providing the digital signal of the
HIGH state.
https://www.instructables.com/id/Working-Without-a-Pull-up-Pull-down-Resistor-With-/
This can be a very misleading tutorial, as one would expect you to talk about the integrated pull-
up and pull-down resistors in the arduino. And how to use them with the code
Yes you are probably right!
Hi
I did this but the led doesn't flicker. I have connected it the way you show in the diagram. Any
ideas?
Yes the LED is less bright. Pressing it gets a HIGH state. Try the second step with the Serial
Monitor on you can see it
I meant to say, It stays on even without pressing the button.