Electronic – Arduino, controlling leds with 3.3V even though dig. has 5V

analogarduinovoltage

The LEDs I have can nicely run on 3.3V, with a minimal power dissipation to bring down 3.3V to 2.0V.

My Arduino has 5V for its digital pins however, and I do not know of a way to use 3.3V unless I use the 3.3V pin and not the digital pins.

To avoid unnessesary power/heat (even if not too much) is it possible to control my LEDs through a lower voltage than what the digital pins provide?

My first thought would be the analogue pins, of which range from 0..255,

5V / 1.5V (analogWrite(pin, 192)) = 3.33V, would this be a good replacement?

Any other suggestions on driving many, but low voltage LEDs?

Best Answer

Indeed, an approach would be, using the PWM capabilities of your controller. You can generate a PWM waveform by using the analogWrite() function.

Parameters for your function: pin: the pin to write to. value: the duty cycle: between 0 (always off) and 255 (always on).

So, if your duty cycle is 255 that means you will have 5V, for 3.3V duty cycle should be somewhere close to 168.

However remember that "On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11". All you need to know about this matter, you can find here http://arduino.cc/en/Reference/analogWrite

Anyhow, don't forget that when dealing with LEDs - polarity is important and also you should (actually must) have a resistor in the circuit so that the current is limited.

Just one more thing - analogWrite, as you may already know, does not use the digital to analogue converter - it uses the PWM capabilities of you controller. This is just FYI :) Regarding the issue that you mentioned "To avoid unnessesary power/heat (even if not too much)" as Olin mentioned above, run you LEDs at low currents. For a standard LED 20mA would be the nominal value. However 20mA is the "recommended" maximum output for your controller outputs :)

Solution: If you think 15mA is OK for the LED and your planning on feeding it at 5V (from a digital output pin) and considering that the diode forward voltage is, as you said, 3.3V use this right here http://led.linear1.org/1led.wiz and you'll see that you're gonna need a 120 Ohm resistor :) A bigger value would lead to a less brighter LED and a smaller value to a brighter one, but keep in mind that a too low value resistor will lead to your controller port being... fried :)

Plan using a lot of LEDs? Try a LED matrix approach, either way I think that what you want is the resistor version, not the PWM.

Good luck and all the best, sorry for the rusty english, Dan