A white LED (Light-Emitting Diode) with two pins is a semiconductor device that emits white light when an electric current flows through it. LEDs are widely used due to their energy efficiency, long life, and compact size. Common applications include indicator lights, backlighting, automotive lighting, and general illumination.
Pin Number | Name | Description |
---|---|---|
1 | Anode (+) | Connects to the positive supply voltage |
2 | Cathode (-) | Connects to the ground (0V) |
R = (Vsupply - Vf) / If
.// Define the LED pin
const int ledPin = 13; // Most Arduino UNO boards have an LED on pin 13
void setup() {
// Set the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Turn the LED on
digitalWrite(ledPin, HIGH);
delay(1000); // Wait for 1 second
// Turn the LED off
digitalWrite(ledPin, LOW);
delay(1000); // Wait for 1 second
}
Q: Can I connect multiple LEDs in series? A: Yes, but ensure the power supply voltage is high enough to provide the forward voltage for all LEDs combined.
Q: How do I calculate the resistor value for a 5V Arduino pin? A: For a typical white LED with Vf = 3.2V and If = 20mA, R = (5V - 3.2V) / 0.02A = 90Ω. Choose the nearest standard resistor value, which is 100Ω.
Q: Can I use a 9V battery to power the LED? A: Yes, but you must recalculate the current limiting resistor value to accommodate the higher voltage.
Q: Is it possible to dim the LED? A: Yes, you can use PWM on an Arduino to dim the LED by changing the duty cycle of the output signal.