What is an LED?

From ROBOTC API Guide
< Tutorials‎ | Arduino Projects/Mobile Robotics/Lego
Revision as of 13:38, 10 August 2012 by Greycompanion (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

What is an LED?

An LED (Light Emitting Diode) is an electronics component that emits light when powered. Like all diodes, LEDs only allow current to flow through them in one direction, meaning that they must be wired in the correct direction in order to function. LEDs have two opposite leads, a cathode (the positive lead) and an Anode (the negative lead). To make it easier to identify which lead is which, LEDs are created with two distinctive properties: The Anode lead is longer than the Cathode lead, and the LED is notched on the side of the Cathode lead. Even if the leads have been damaged or clipped, you can still look for the notched part of the LED to identify the cathode.

Close up of an LED and one of the possible schematic symbols for an LED.

When referencing a schematic (drawing of the electrical pathways and components using symbols), the symbol for the LED shows which way the current flows and allows you to connect the LED the correct way. The cathode on the symbol is the side with the line across the point of the triangle and the anode is the other side. It is important to note that there are many variations on the schematic symbol, however, they all have a triangle with a line across the point and one or two arrows pointing out.

How to Wire an LED

Warning.png WARNING: Wiring anything while there is power running through it is always a bad idea, due to the possibility of serious electric shock. Make sure that there is no power going to the robot before you insert or move anything on the DFRobot Motor Shield or breadboard.

To wire an LED, you need an LED, a breadboard, some wires, and a 470Ω resistor (color code: yellow-violet-brown). A resistor is an electronics component that limits the flow of electricity. This is important because some components, like LEDs, will be damaged or destroyed if too much current flows through them. Thus, we need resistors to protect the LED.

LED parts

Wiring an LED is very simple. All you need to do is connect one lead of the resistor to digital pin 5 on the Arduino. Connect the other lead of the resistor to the anode lead of one of the LEDs, and then connect the cathode to ground.

LED Circuit Schematic

To make this easier, we will use the breadboard. Breadboards allow us to easily connect different electronics pieces together on a temporary basis (i.e. without requiring us to solder them together). Which means that we can easily change the configuration of our robot at any time, starting with using the breadboard to create our first configuration.

Virtual Breadboard setup
Breadboard setup

Understanding the circuit

The Arduino digital pin in this circuit is configured as an output, which in this setup can be thought of as connecting the circuit to the power when set to high, or disconnecting it when set to low. When it is connected, the current will flow from the pin, through the resistor and through the LED, then into the ground connection. (In electronics, the ground connection refers to the voltage supply connection that has 0 volts). The LED requires about 2 volts across the leads to operate correctly. However, The Arduino's main power supply provides 5 volts, 3 volts too many. Thus, we use a resistor to bring the voltage down to an appropriate level

For a series circuit (one in which the components are connected one after the other), the sum of the voltage drop (voltage drop - the amount of voltage used by a component, i.e. the difference in voltage across the connections) across each component must be equal to the source voltage, which in this case is 5 volts. Since the LED needs 2 volts, the resistor must have a voltage drop of 3 volts. Additionally, in series circuits the current (amperes or amps abbreviated as A) flowing through each component is the same. Based on these two properties, it is possible to calculate the required resistance of the resistor using (Vs·VLED)/ILED=R, where Vs is the supply voltage, VLED is the voltage across the LED, ILED is the desired current flowing through the LED, and R is the resistance of the resistor. We already selected the 470Ω resistor because it provides a nice safety range for variances of the components.