When electricity passes through an LED, electrons fill electron holes in the semiconductive material, and energy is released in the form of photons. The color the light takes is determined by the band gap of the semiconductor. As with any diode, electricity can only pass in one direction. The cathode is connected to ground, typically has a longer leg, and is topped by an anvil to hold the semiconductor in place.
int ledPin = 9;
ReplyDeleteint lux = 1;
void setup(){
}
void loop(){
for(int i = 0; i < 254; i++){
analogWrite(ledPin, lux);
lux++;
delay(100);
}
for(int j = 0; j < 254; j++){
analogWrite(ledPin, lux);
lux--;
delay(100);
}
}