I have a project that (in part) will drive 3 LEDs where the LED anodes are at 12V. The thought is to drive each LED by connecting each cathode to a 650 ohm resistor, and connect that to an Arduino DIO pin which, when needed, is set to output LOW. Arduino VIN = same 12V with common ground. Am I going to have an Arduino problem of any sort?

  • Why would you want to do that? Do you want to switch the LED on/off by changing the digital HIGH/LOW state of the Arduino pin? If so, no, that will not work. Depending on the power consumption of the LEDs you could (i) low power, drive directly from the Arduino like in the Blink example, (ii) high power, drive via the same code but with a transistor in between the IO pin and LED. – MichaelT May 1 at 8:34
  • That doesn't work. When you set the pin to output LOW, then leds will be on (like you want). But if you set the pin to output HIGH, the voltage is 5V, so there is still 7V (12V - 5V) across the leds, and the leds will light up dimly. If you set the pin to input, the voltage at the pin will become around 12V, which exceeds the allowed voltage. The clamping diodes inside the MCU will clamp the voltage to around 5V, so the leds will still be on, dimly, and the internal clamping diodes will die from overheating, potentially destroying the the entire MCU. – Gerben May 1 at 13:40
  • The detailed Gerben explanation is the WHY my approach will not work. Thanx. – Ange Purs May 1 at 23:04

No, what you propose will not work. And it risks damaging your Arduino.

Normally you would include a single transistor which the Arduino uses to control the power through the LEDs. This removes the 12V from the Arduino and turns the output into an actual switch.

The problem is that the Arduino's GPIO isn't just a single transistor. It is (amomgst other things):

  • Two complimentary transistors (that's the C in CMOS) for HIGH and LOW switches
  • ESD Diodes
  • Input buffer

By just adding the one transistor like this:


simulate this circuit – Schematic created using CircuitLab

the 12V is kept well away from the Arduino. Setting the output HIGH will turn on the transistor, allowing the current to flow to ground. Setting it LOW with turn it off, blocking the flow of current and switching the LEDs off.

Further: the Arduino's GPIO has a maximum sustained current of 25mA. Ideally you don't want to even come anywhere near this. By adding the transistor it acts as a buffer and allows you to deal with much higher currents - and hence more, and brighter, LEDs.

Incidentally, R1 in that schematic is there solely to keep the transistor off when the Arduino is not actively driving the output - e.g., when it's either unpowered or is running the bootloader - or you happen to have the GPIO in INPUT mode (as it defaults to).

  • Thank you. I am aware of the transistor approach, altho I had not considered the addition of R1 and using a mosfet. Each Arduino output will be driving only one LED. My original post was motivated by a desire to minimize the component count needed to drive each LED...and to have a better understanding of Arduino I/O limitations. – Ange Purs May 1 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.