A green LED (Light-Emitting Diode) with two pins is a semiconductor light source that emits green light when an electric current flows through it. LEDs are widely used in various applications due to their low power consumption, long service life, and compact size. Green LEDs, in particular, are often used in electronics to indicate power status, signal messages, or as part of user interfaces.
Pin Number | Name | Description |
---|---|---|
1 | Anode (+) | Connects to the positive supply voltage |
2 | Cathode (-) | Connects to the ground (0V) |
R = (V_supply - Vf) / If
.// Define the LED pin
const int ledPin = 13; // Most Arduino UNOs have an onboard LED on pin 13
void setup() {
// Set the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Turn the LED on (HIGH is the voltage level)
digitalWrite(ledPin, HIGH);
// Wait for a second
delay(1000);
// Turn the LED off by making the voltage LOW
digitalWrite(ledPin, LOW);
// Wait for a second
delay(1000);
}
Note: The onboard LED on the Arduino UNO is connected with a built-in resistor, so you do not need to add an external current-limiting resistor for pin 13. However, for external LEDs, always include a resistor in the circuit.