LED interfacing with PIC Microcontroller

///LED interfacing with PIC Microcontroller

LED interfacing with PIC Microcontroller

The world of electronics has always been vibrant as many exciting new devices and circuits getting added to the overflowing number of devices. Many devices are getting replaced often with the advancement of technology. There are several devices which have proven themselves to be irreplaceable as they have been found quite convenient for different applications. Light emitting diode is such a device and this chapter deals with various aspects of interfacing an LED with a PIC microcontroller.

What is an LED

An LED is basically a p-n junction diode which emits light energy when adequate voltage is given. Light emitting diodes (LED) are basic display units in electronics world. It has found its way to the low power display systems recently. It is the most commonly used indicator lights in all the applications. Ever since it’s wide spread use as reliable electronic component, LEDs have been ruling the electronic arena as no other similar technology has ever replaced them.

LED bulbs are available in different colours. Earlier LEDs made use of the infra-red wavelength and such LEDs are used even these days in remote-control circuits. LED bulbs making use of the ultra violet wavelength is also available in the market.

As discussed earlier, LEDs are present in many electronic devices including lamps, digital clocks and incandescent bulbs. A very popular application of LED is a seven segment display system. The advantages of LEDs over normal incandescent lights include robustness, faster switching, lower energy consumption and small size.

LED requirements

There are two technical specifications that should be taken into account while interfacing an LED. There are other specs like luminous intensity, dominant wavelength, operating temperature etc. Other specifications can be ignored while designing the circuit.

  1. Peak forward current
  2. Continuous forward current
  3. Forward voltage
  4. Reverse voltage

Peak forward current

The current above maximum forward current’s limit may damage the LED. For red LED, peak forward current is 100mA. Use the datasheet to find these rating.

Continuous forward current

This is optimum current required by the LED, we use this current in our designing process.

Forward voltage

It is the voltage required by a diode to turn it on. This voltage range is 1.8 – 2.2V for red/orange/yellow LEDs, green/blue/white LEDs have a forward voltage of around 3.4V.

Reverse voltage

This voltage indicates how much voltage you can give in reverse direction before it get blown.

Interfacing LED

Current passing through the LED should be limited to maximum forward current (IF). For this, a resistor is used. To find the value of this resistor, we use the forward voltage and forward current.

LED interfacing We design a circuit with 5V supply and forward current of 20mA. We use a red LED here.

R = (5 – 2)/20mA = 150 ohms

LED interfacing with PIC

Now we know how to design a circuit for LED. This circuit can be used to interface with PIC microcontroller. One of the technical specifications to be taken in account is the current which can be sourced from a microcontroller pin (maximum pin Source current = 25mA for PIC18F4550). It should be more than what we are using. Datasheet will provide this information.

LED interfacing with PIC18F4550

LED driving from RB0 of PIC18F4550

In this case, it is safe to assume that 20mA of current can be sourced from the microcontroller.
Now the firmware part,
Set the port as output.

Toggle the port bit and give a delay in between the operation to give a blinking effect.

LED driving

We’ve done a basic circuit, it is sufficient to work most to the time. The current is sourcing from the microcontroller. In this case, we are driving only the LED, there is no need of concern. But as the number of modules used in application increases, the current driving may not be sufficient. To solve this, we use external current drivers.

External current driver circuits can be designed based on our requirements or we can use current driver ICs.

Current driver IC

When using LEDs in displays and other illuminating applications, we need predictable and matched luminous intensity from every LEDs. Also we need to make sure that the current should be always in the optimum ratings. In order to achieve this, we need to use constant current drivers.

There are many current driver chips available in market. One of the commonly used chips is ULN2003. It is a Darlington pair based current driver which is capable of 500mA current output. LED drivers with PWM capability are also available in the market with brightness controlling capability. CAT4101 from ONSEMI is an example for this.

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
Spread the love, share this

Leave A Comment

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
close-link
25% OFF - OpenLabPro Course
Use Coupon: CRS25UL

 
PIC Microcontroller Primer
Want to learn indepth programming, peripheral interfacing and driver development?
close-link
Launched: IoT online Course - 25% Off when you complete your order today.
Checkout Now
close-image

Subscribe To our Email Newsletter

Be the first to get latest updates and exclusive content straight to your email inbox.
Send me Tutorials and Guides
close-link