LED Interfacing

What is an LED?

LED is a two-lead semiconductor device (Light source device).

LED stands for Light Emitting Diode.

Wherever Diode is there it means it allows the flow of current in only one direction and it opposes the flow of current in other direction. To glow LED with sufficient intensity it typically requires a current of about 20 ma and voltage of about 2V. The voltage range is between 1.8V to 3.3V for LED. It depends on which color of LED you are using. For RED LED 1.8 V would be sufficient, for green 2.1 V is enough. However, GREEN and BLUE LEDs can withstand up to higher voltage than the RED one.

As we just came to know that LED typically requires 2V. But most of the microcontrollers give +5V at Port Pins, so how do we get 2V from this 5V. That means somehow we need to drop this extra 3V. So we will use resistors for that purpose.

Which value of Resistor to use should we use?

Ohm`s law

According to ohm s law

R = V/I                        V =  IR                        I = V/R

Where,

R = Resistor

V = Voltage

I = Current

So required value for the resistor to connect the single LED to the microcontroller pin is

Req = (VolateSupply – VolategeLedRequires)/CurrentLedRequires

Where,

Req = Equivalent Required Resistance(ohm)

VolateSupply = Supply Voltage(volt)

VolategeLedRequires = Required Voltage for LED(volt)

CurrentLedRequires = Current Required for LED(ampere)

Assume supply voltage is 5V

Connecting LED at one of the microcontroller pins.

Req = (5 – 2)V/20ma

Req = (5-2)V/0.020A

Req = 3/0.020

Req = 3 * 1000/20

Req = 150 Ohm

So any Resistor we are having a resistance of 150 ohms or greater will serve the purpose. Typically people choose a 220 Ohm resistor. We can go slightly less than 150 ohm that’s okay but we would not go with too much low value of register because we do not want our LED to burn out.

LED terminals

LED has two terminals. Cathode(K) and Anode(A). The longer lead is called Anode and the shorter lead is called Cathode.

LED symbol

symbol-of-led

How can we turn on the LED?

To turn on LED:  Anode of the LED has to be connected at higher potential (at least equal to or more than the voltage required to turn ON LED[approx 2V]) with respect to the cathode.  The positive terminal of the Battery or any other voltage source has to be connected to the Anode of LED and the Negative terminal of the Battery or any other voltage source has to be connected to the Cathode of LED.

How can we turn on the LED connected to the microcontroller?

LEDs can be connected to a microcontroller in either of these ways.

  1. Anode of LED is connected to MCU Pin and Cathode of LED to Ground.
  2. Cathode of LED is connected to MCU Pin and Anode of LED to +5V.
  3. Both the Anode and Cathode of LED are connected to MCU Pins.
1] The anode of the LED is connected to MCU Pin and the Cathode of the LED to the ground.

AnodeToMCU

In this connection, the cathode is already connected to the ground so the only thing which we need to do is to give high logic to MCU Pin (at which LED is connected) to turn on the LED.

2] The cathode of the LED is connected to MCU Pin an anode of the LED to +5V.

In this connection, Anode is already connected to supply voltage(+Vcc). So we just need to give low logic to MCU Pin (at which LED is connected) to turn on the LED.

CathodeToMCU

3] Both the anode and cathode of LED are connected to MCU Pns.

AnodeCathodetoMCU

In this connection both of the LED lead is connected to MCU Pin so in order to turn ON LED we need to give high logic to MCU Pin at which the Anode of LED is connected and need to give low logic to MCU Pin at which Cathode of LED is connected.

NOTE:- Don`t forget to connect the resistor between MCU Pin and LED.

Here in circuit 110 Ohm resistor is connected to limit the flow of the current.

LEDs Can be used

  •  As an Indicator
  •  In Dot matrix
  •  In 7 segment Display Devices
  • Traffic signal
  • Camera flashes
  • General Lighting

Thank you for reading…

 

Leave a Comment

Your email address will not be published. Required fields are marked *