Beginner Question About LED's

Now i am trying to use an LED on a pin other than 13,

I goggled but come up with two different connections

#1 -> uses pin10 connected to resistor (330 ohm) connected to + of the LED and - of the LED is connected to ground.

#2 -> uses pin10 connected + of the LED - of the LED is connected to the resistor and it is connected to the ground.

From my limited electronics knowledge #1 must be the correct one we decrease +5v to not damage the LED. Am i wrong here or are both these setups correct?

Thanks.

So to put it simple, the resistor is swapped from the cathode to the anode of the led. I dont see any issue with either of the two.

You can easily test these by modifying the pin number on the blink example. Also check out the pull-up and down examples in the playground.

Hope this helps.

for a basic led setup, it does not matter which side the resistor is connected to, its still restricting the flow of electricity from point A to B

and therefore limiting how much power the led has to consume

OK so my misconception is it does not matter which side we put the resistor it will still reduce the voltage on the whole setup.

I was thinking, i need to reduce the voltage before it hits the LED, that's why it seemed weird to connect the resistor after the LED.

So i should think of the more like a water pipe no matter where you slow it it will slow down the whole flow.

pretty much, but focus more on current and the voltage difference being a side effect

The consideration should be on whether you are using the I/O pin to 'sink' or 'source' the current to drive the LED.

If you are using the I/O pin to source(ie. where you connect the + to the I/O pin and - to ground), then you don't need a current limiting resistor in series with the LED, because the I/O pin has a pull-up resistor inside the atmel chip, and protection diodes for kick-back.

If you are using the I/O pin to sink(ie. where you connect LED + to VCC and - to the I/O pin), then you need a current limiting resistor, because the I/O pin can only sink so much current before you blow the channel's driver.

If you are using the I/O pin to source(ie. where you connect
 the + to the I/O pin and - to ground), then you don't need a current
 limiting resistor in series with the LED, because the I/O pin has a pull-up
 resistor inside the atmel chip, and protection diodes for kick-back.

That is flat wrong. No matter if you are sinking or sourcing current from an Arduino digital output pin, you need an external current limiting resistor when driving a LED.

The software enabled optional pull-up resistor is a feature used for digital input pins only , nothing to do with digital pins that are set up to be output pins.

Lefty

That is flat wrong. No matter if you are sinking or sourcing current from an Arduino digital output pin, you need an external current limiting resistor when driving a LED.

The software enabled optional pull-up resistor is a feature used for digital input pins only , nothing to do with digital pins that are set up to be output pins.

Lefty

Well, I stand corrected. My apologies. I should have read the data sheet more carefully.