2

arduino Please, iam a junior in arduino and i want to know what is the importance of the resistors that connect to push buttons? can i replace them by wires? thanks in advance.

0

1 Answer 1

6

They are what is known as Pull-Up resistors. The circuit will not work if you replace them with wires. Not only that but you will short circuit the power supply when you press a button.

Why don't you want to use resistors?

The value is not important - you could use the same value as you are using for the LED if you don't have the 10k resistors shown in the drawing.

Having said that an alternative is to leave them out and instead activate the internal pull-ups within the processor on the Arduino:

pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors
3
  • 1
    I'd say that it's not "an alternative", it's the sane thing to do :-) Why using additional components when there are integrated ones that are perfectly suitable for the purpose? I think the situations that require using external pullups are really few and not too likely to happen to someone who's just starting to move the first steps. Sep 3, 2015 at 10:32
  • 4
    Or use the single line pinMode(pin, INPUT_PULLUP); (which in effect does the same thing, but is a bit shorter, and more intuative)
    – Gerben
    Sep 3, 2015 at 13:40
  • I'm having an issue with your comment about short circuiting the power supply but am likely just "splitting hairs".
    – linhartr22
    Sep 3, 2015 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.