Drive LED or Opto-isolators with AVR

This might be seem very simple to many of you, but I still get questions about simple microcontroller interfacing. So I will put a thread of notes about interfacing AVR microcontrollers to devices like LED’s, relays, I2C, etc.

As you might know Diodes require pretty small current. This current depends on diode type and can be from 3mA up to 20mA and more. Working voltage is from 1.5 to 4V.

One AVR pin can sink up to 20mA of current; it is convenient to connect diode directly to it with current limiting resistor. Never connect diode to pin without resistor – you may damage your AVR as your current may exceed the 20mA limit!

There are two ways to drive LED’s with AVR: sink and source. Sink method is better, because tour microcontroller doesn’t have to generate current to power LED’s. This may be critical when connecting more Diodes to AVR.

image001.png

When connecting more than one diode, just remember that there is a maximum current that microcontroller can drive. For example Atmega8 maximum current can be 200mA.

The same situation is with opto-isolators as inside them there are the same diodes packed together with sensors. Optoisolators are convenient when you need to untie the controller from power circuits.

FYI: Current limiting resistor can be calculated very simply. Find out maximum current LED can handle and divide applied voltage by this current then you will have resistance of your resistor. R=5V/20mA=250Ohm. I usually double this resistance as I don’t like to drive my LED’s on maximum.

Blogsphere: TechnoratiFeedsterBloglines
Bookmark: Del.icio.usSpurlFurlSimpyBlinkDigg
RSS feed for comments on this post
 |  TrackBack URI for this post

New on WinAVR Tutorial
Running TX433 and RX433 RF modules with AVR microcontrollers,
Sometimes in embedded design you may want to go wireless. Might be you will want to log various readi …
Programming AVR ADC module with WinAVR,
Most of AVR microcontrollers have Analog to Digital Converter (ADC) integrated in to chip. Such solut …
New on WinARM Tutorial
What are differences between WinARM and WinAVR,
Everyone who is working with AVR microcontrollers knows this powerful tool – WinAVR (http://win …
LPC2000 watchdog timer,
As in all microcontrollers watchdog timers purpose isto reset microcontroller after reasonable amount …

Leave a Reply