A Light Emitting Diode (LED) is a semiconductor device that emits light when an electric current passes through it. The two-pin red LED is a specific type of LED that produces red light and is commonly used in electronics for indicators, displays, and illumination. Due to its simplicity and low power consumption, it is widely used in various applications such as power-on status indicators, traffic lights, and decorative lighting.
Pin Number | Name | Description |
---|---|---|
1 | Anode (+) | The positive lead that should be connected to the supply voltage. |
2 | Cathode (-) | The negative lead that should be connected to ground. |
R = (Vsupply - Vf) / If
.// Define the pin connected to the LED
const int ledPin = 13; // Most Arduino UNO boards have an onboard LED on pin 13
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as an output
}
void loop() {
digitalWrite(ledPin, HIGH); // Turn on the LED
delay(1000); // Wait for 1 second
digitalWrite(ledPin, LOW); // Turn off the LED
delay(1000); // Wait for 1 second
}
Q: Can I connect the LED directly to a 5V supply? A: No, you should always use a current-limiting resistor to prevent damage to the LED.
Q: How do I calculate the resistor value for a 5V Arduino output?
A: Using Ohm's Law, R = (Vsupply - Vf) / If
. For a 5V supply and a typical red LED, R = (5V - 2V) / 0.015A ≈ 200Ω
. A standard 220Ω resistor is a common choice.
Q: Can I use PWM to dim the LED? A: Yes, you can use pulse-width modulation (PWM) on a digital pin of the Arduino to control the brightness of the LED.
This documentation provides a comprehensive guide to using a two-pin red LED in electronic circuits. Always follow the technical specifications and best practices to ensure the longevity and proper functioning of the LED.