Controlling LED at 120mA with analog pin

Hello,

I want to control an LED that draws 120mA of current with an analog pin (digital ones are used). The Atmega is rated at 40mA.

I thought of 2 possible solutions: - interrupt the LED circuit at the ground wire by using a 2N2222 transistor. - interrupt the LED circuit at the (+) wire by using a relay.

Using the 2N2222 would be cheaper and easier for me (I already have one). Can I interrupt the LED circuit on the ground wire without causing problems for the Atmega, the LED or the entire setup? I am thinking of putting a 1N4004 (also have one) diode at the analog pin.

Any feedback is appreciated. If anyone has other suggestions, I would love to hear them.

Thank you!

120mAh of current

mAh aren't current... do you mean simply mA?

Yes, sorry for that!

mA, not mAh.

Silly mistake. :blush:

This tutorial is basically what you want to do. As you suggested, interrupt the ground side so that with an npn transistor like the 2n2222, the load (the led) is on the collector (high) side.

But I'm confused about what you mean by controlling with an analog pin? The analog pins are inputs... if you mean to control the brightness, you would do that with an analog write yes, but on a digital (pwm) pin, which is a "pseudo"-analog approach.

Thank you for your reply!

From what I understood here, http://arduino.cc/en/Tutorial/AnalogInputPins I can use the analog pins as general purpose input/output pins.

Yes, sorry, I thought you were talking about analog output...

you put the emitter of your transistor to GND, the base to the arduino output via a series resistor and the collector becomes the new negative for your LED

numlo: Thank you for your reply!

From what I understood here, http://arduino.cc/en/Tutorial/AnalogInputPins I can use the analog pins as general purpose input/output pins.

In which case they are no longer analogue pins, they are digital outputs.

becomes the new negative for your LED

and its associated resistor.