input-pullup

if i use the input-pullup command do i still need a resistor on the output to turn a led on/off

Consider - one says INPUT_PULLUP, the other is an output.

What does that suggest? :grinning:

Incidentally, if you connect a high efficiency LED (which is to say, most currently manufactured small LEDs) between a pin set as INPUT_PULLUP and ground, it will glow albeit not very brightly. :astonished:

Forbesy:
if i use the input-pullup command do i still need a resistor on the output to turn a led on/off

Yes.

Let me clarify that a bit as the question is - as it is so often - vague. :grinning:

If you are defining a pin as OUTPUT and using it to drive a LED, then you do need a current limiting resistor in series. This is entirely independent of what other pins you may be using as outputs or inputs whether or not in pinMode of INPUT_PULLUP; it relates only to that particular pin. For the ATmegaxx8 and similar devices, it is advised to limit the current to 20 mA which generally corresponds to a 150 Ohm resistor to drive a LED. It would be slightly different for processors running at 3.3 V. And you mostly do not need full brightness so a much higher resistor value is usually just fine.

OK, now you could connect an LED directly between a pin and ground and define its pinMode as INPUT_PULLUP, then digitalWrite it HIGH and LOW to turn it on and off. It would be very dim, but a decent LED will glow. We sometimes see here people who complain that their LEDs work but are not bright and it is because they have failed to set them as an OUTPUT. Having the pin default to an INPUT and writing it HIGH is the same as INPUT_PULLUP with an effective pull-up value of about 47k.

Even so, it is not advised to connect a LED without the resistor as you may forget and set it as an OUTPUT. The microprocessor itself is most unlikely to do this by accident (that is, crash), but the code you write just might. :astonished: