I am using a 3.3V uC (ATMega 328p in Arduino Pro Mini) running from 3 alkalines (nominal 4.5V). So Vin=4.5V, Vcc=3.3V
I'd like to drive LEDs from some pins, say at 20ma each. And I was thinking to connect the LED anodes to Vin (4.5v) with the cathode going to the uC pin, rather than putting all the LED currents through the 3.3v onboard regulator. (Also, while I'll use Red LEDs in the example here, I may want to use Blue as well, which would be more comfortable with a bit more driving voltage).
I figure a red LED at about 2v Vfwd, so the resistor would need to drop 2.5v @ 20ma, say 1K2 ohms.
The issue: this connect a uC pin to a source 1.2V about its Vcc rail (through an LED).
I think we are fine when the LED is on (pin low). But what about turning the LED off?
Approach 1: Pull uC pin high (3.3v) to turn off the LED. The LED is between 4.5V and 3.3V, and the 1.2v difference will not be enough to light it - and I THINK it also won't bring the pin too high above its rail. But LEDs are not ideal devices, hence this question.
Approach 2: tristate uC pin (make it an input) to turn off the LED. The LED is between 4.5V and the high impedance input (along with it's static protection diode to Vcc). Again, I hope the LED's Vfwd would be enough protection for the uC pin.
Is either or both of these approaches workable and safe for the uC?
EDIT: substitute 120 ohm resistor above, oops.