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?
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.
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.