Ships worldwide · rates shown at checkout
Free help & advice · we reply within 24 hours
30-day returns · 12-month warranty on faults

02 - LED

Lonely Binary |

# LED (Light Emitting Diode) ![LED](/配件/LB-COMPONENT-SET/images/components/LED.png) ## What is LED LED (Light Emitting Diode) is an electronic component that can emit light. ### LED Features - **Low Power Consumption**: Much more energy-efficient than traditional bulbs - **Long Lifespan**: Typically can be used for tens of thousands of hours - **Fast Response**: Extremely fast switching speed, suitable for digital control - **Small Size**: Easy to integrate into various circuits - **Multiple Colors**: Red, green, blue, yellow, white, and other colors available ### How LED Works LEDs contain special semiconductor materials. When current flows from anode to cathode, electrons and holes combine to release energy in the form of light. Different materials emit different colors of light. ## Polarity Identification LED has two pins and **must be connected correctly to emit light**. Reversed connection won't emit light, but usually won't damage the LED. ### Identification Methods #### Method 1: Pin Length (Most Common) - **Anode (+)**: **Long pin** - **Cathode (-)**: **Short pin** **Memory tip**: Long pin is positive (+), short pin is negative (-) #### Method 2: Internal Structure Observation If the pins are cut short, observe the LED internal structure: - Hold the LED up to light, you can see two metal electrodes inside - **Smaller electrode** connects to **anode**, **larger electrode** connects to **cathode** #### Method 3: Marking Symbols Some LEDs are marked on the housing: - `+` or `A` indicates anode - `-` or `K` indicates cathode ### Why Must Polarity Be Distinguished? LED is a **diode** with **unidirectional conductivity**: - **Forward Connection** (anode to high potential, cathode to low potential): LED conducts and emits light - **Reverse Connection** (anode to low potential, cathode to high potential): LED does not conduct, does not emit light (but won't be damaged) ## Current Limiting Resistor ### Why Must Current Limiting Resistor Be Used? **Important**: LED **absolutely cannot** be directly connected to power supply, must be connected in series with a current limiting resistor! #### Explanation 1. **LED Operating Characteristics** - LED operating voltage is typically **1.8V - 3.3V** (varies slightly by color) - LED operating current is typically **5mA - 20mA** - LED resistance is very small, almost negligible 2. **Consequences of Direct Connection** - If LED is directly connected to 5V power supply - According to Ohm's law: I = U / R - LED resistance is very small, current will be very large (may exceed 100mA) - **Excessive current will instantly burn out the LED**, LED will smoke, turn black, and stop emitting light 3. **Role of Current Limiting Resistor** - Limits current through LED - Drops excess voltage across the resistor - Protects LED from being burned out ### Current Limiting Resistor Calculation Method #### Calculation Formula ``` Current Limiting Resistor R = (Power Supply Voltage - LED Operating Voltage) / LED Operating Current ``` #### Practical Calculation Examples **Example 1: 5V Power Supply, Red LED** - Power supply voltage: 5V - Red LED operating voltage: approximately 2.0V - Recommended operating current: 20mA = 0.02A Calculation: ``` R = (5V - 2.0V) / 0.02A = 3V / 0.02A = 150Ω ``` **Select Standard Value**: Use **220Ω** (slightly larger than calculated value, safer) **Example 2: 3.3V Power Supply, Red LED** - Power supply voltage: 3.3V - Red LED operating voltage: approximately 2.0V - Recommended operating current: 20mA = 0.02A Calculation: ``` R = (3.3V - 2.0V) / 0.02A = 1.3V / 0.02A = 65Ω ``` **Select Standard Value**: Use **100Ω** or **220Ω** ### Common Current Limiting Resistor Value Reference Table | Power Supply Voltage | LED Color | Recommended Resistor Value | Notes | |---------------------|----------|---------------------------|-------| | 5V | Red | 220Ω - 330Ω | Most common | | 5V | Green/Blue | 220Ω - 470Ω | Slightly higher operating voltage | | 5V | Yellow/White | 220Ω - 1KΩ | White LED has higher voltage | | 3.3V | Red | 100Ω - 220Ω | Common for 3.3V systems | | 3.3V | Green/Blue | 100Ω - 330Ω | Adjust according to brightness | **Tip**: Larger resistor value makes LED dimmer but safer, smaller resistor value makes LED brighter but be careful not to exceed maximum current. ### Connection Method #### Breadboard Connection Diagram ![LED Circuit Diagram](/配件/LB-COMPONENT-SET/images/circuits/led_circuit.png) #### Connection Instructions According to the diagram above, connection order is: ``` VCC (5V) → Current Limiting Resistor (220Ω) → LED Anode (long pin) → LED Cathode (short pin) → GND ``` **Key Points**: - Current limiting resistor must be connected (cannot be omitted) - LED anode (long pin) connects to resistor, cathode (short pin) connects to GND - Resistor has no polarity, both ends can be swapped - Ensure circuit forms complete loop (from VCC to GND) **Note**: - LED must be used **in series** with current limiting resistor - **Absolutely cannot** directly connect LED to power supply, will burn out immediately! ## Arduino Example Code ### Basic Example: LED Blink ```cpp // Define pin connected to LED const int ledPin = 13; // Use Arduino onboard LED or connect external LED void setup() { // Set pin to output mode pinMode(ledPin, OUTPUT); } void loop() { // Turn on LED (output high level) digitalWrite(ledPin, HIGH); delay(1000); // Wait 1 second // Turn off LED (output low level) digitalWrite(ledPin, LOW); delay(1000); // Wait 1 second } ``` ### Connection Method - **LED Anode** → 220Ω resistor → **Arduino Pin 13** - **LED Cathode** → **GND** ### Code Explanation - `pinMode(ledPin, OUTPUT)`: Set pin to output mode - `digitalWrite(ledPin, HIGH)`: Output high level (5V), LED on - `digitalWrite(ledPin, LOW)`: Output low level (0V), LED off - `delay(1000)`: Delay 1000 milliseconds (1 second) ### Advanced Example: PWM Dimming ```cpp const int ledPin = 9; // Must use PWM-capable pin (3, 5, 6, 9, 10, 11) void setup() { pinMode(ledPin, OUTPUT); } void loop() { // Gradually brighten for (int brightness = 0; brightness <= 255; brightness++) { analogWrite(ledPin, brightness); delay(10); } // Gradually dim for (int brightness = 255; brightness >= 0; brightness--) { analogWrite(ledPin, brightness); delay(10); } } ``` **Explanation**: - `analogWrite(pin, value)`: PWM output, value range 0-255 - 0 = darkest (off), 255 = brightest - Only pins marked with `~` support PWM ## Common Questions and Answers ### Q1: LED Not Lighting Up? - Check if polarity is reversed (try swapping pins) - Check if current limiting resistor is connected - Check if power supply is powered, GND is connected - Check if LED is damaged (try another one) ### Q2: LED Too Dim? - Current limiting resistor value too large, try smaller resistor (e.g., 100Ω) - Power supply voltage insufficient, check power supply voltage - Different color LEDs have different brightness, white and blue are usually brighter ### Q3: LED Burned Out? - **Forgot to connect current limiting resistor** (most common cause, must use current limiting resistor) - Current limiting resistor value too small, use larger resistor value (at least 100Ω or more) - Power supply voltage too high, check if power supply voltage is correct ### Q4: Can Multiple LEDs Be Connected in Parallel? Yes, but **each LED needs its own independent current limiting resistor**, cannot share one current limiting resistor among multiple LEDs. ## Safety Precautions ⚠️ **Important Notes**: - **Must use current limiting resistor**, otherwise LED will burn out immediately - Do not exceed maximum current (typically 20mA) - Reversed LED connection won't damage it, but won't emit light - Avoid static electricity, do not stare directly at high-brightness LEDs ## Practical Applications LEDs are commonly used for status indication, decorative lighting, displays, signal lights, backlighting, etc. With Arduino, you can create blinking lights, breathing lights, running lights, color mixing, and other creative projects.