Go Down

Topic: Pull-up or Pull-down? (Read 4719 times) previous topic - next topic

ElCaron

#15
May 31, 2017, 07:49 am Last Edit: May 31, 2017, 08:35 am by ElCaron
Quote
1. Use a resistor with a LED, that is, don't depend on the internal pullup resistor.
You cannot just "depend on the internal pullup resistor" for an LED. It is not in appropriate position in the circuit. There IS a hack to run an LED over it very dimly, but it requires different code! (Your driving pin that you use to switch the LED on and off would actually be set as an input for that hack.) So in my opinion, it was a very confusing, very unnecessary smartass remark to bring that hack into the game here.

Smajdalf

#16
May 31, 2017, 10:26 am Last Edit: May 31, 2017, 10:27 am by Smajdalf
You cannot just "depend on the internal pullup resistor" for an LED. It is not in appropriate position in the circuit.
I don't want to have theological argument about "appropriate position in circuit". The part of IC named "pull-up resistor" may be used as current limiting resistor to drive a LED. Possibly it is not be intended use but is there any problem? (Rhetorical question - I am aware about one but it is negligible.)

So in my opinion, it was a very confusing, very unnecessary smartass remark to bring that hack into the game here.
In OP there was question:
Now then, if the built-in resistor on the Arduino board diminishes the current, why not build a breadboard layout with a LED and no external resistor, for use with the DigitalInputPullup Example?
I answered the question. Answering to OP is "unnecessary smartass remark"?

Back to the topic. In fact since I discovered this is possible I use it frequently for quick solderless breadboard experiments. Example:



The large chip is ATMega328p, all the LEDs except for the too bright red LED on the right are powered from internal pull-up (only 3 are turned on at the moment). I cannot imagine the mess if I used external current limiting resistors for all of them. It would probably need one extra breadboard.
Also note: software fault (driving LED without current limiting) = damaged LED, pin driver should survive. Hardware fault (touching legs of two "current limiting resistors") = destroyed drivers of one or both pins in contention. It is easy to do hardware fault yourself. If wife/pet/young brother "helps" you it is inevitable.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

ElCaron

I answered the question. Answering to OP is "unnecessary smartass remark"?
That's debatable. The question was, if there is a current limiting resistor that protects an LED when it is driven by a pin. The asking poster clearly didn't understand the difference between a pullup and an in-series resistor.
Quote
Now then, if the built-in resistor on the Arduino board diminishes the current
For that, the answer is "No!". Not "Yes, you can use it for current limiting if you understand that you need completely different code and this is basically some kind of hack"

Smajdalf

I have read the OP again (and again and again). It is a bit confusing but states "DigitalInputPullup" three times. I expected the OP knows difference between OUTPUT, HIGH and input with pull-up. After looking on schematic again it is probably not the case. Still the OP asked if internal pull-up resistor may be used to drive LED and if the schematic is right. So it may be used for this but the schematic is WRONG. It is possible to connect
pin X --- LED --- GND
without any resistor and light the LED by pinMode(X,INPUT_PULLUP). In this case using pinMode(X,OUTPUT) will burn the LED if pin X is set HIGH.
The pull-up resistors are not "on the board" but "inside the chip" if it makes a difference.

(As a side note IIRC digitalWrite(x,HIGH) also activates the pull-up if the pin is in input mode and digitalWrite(x,LOW) deactivate it.)
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

Go Up