Interfacing an LED to a microcontroller
First identify which is the anode and cathode,the shorter leg is the cathode(negative) and longer leg is anode(positive).
Now we will see how to interface a LED to a microcontroller. We can do this in two ways.
Method 1: Connect the anode to a microcontroller GPIO pin and cathode to ground with a resistor connected between anode and the microcontroller pin , to reduce current flowing into the led . The value of the resistor depends on the amount of the current that can be supported by the LED.In order to ON the LED we have to send a Logical High from the microcontroller pin.
Method 2: Connect the cathode to the microcontroller GPIO pin and anode to the 5V with a resistor i between. Now we have to send a logical LOW from the microcontroller pin for making the LED glow
Comments
Post a Comment