Limit the current flow through the LED with a small resistor R1, ca 200~1000Ω. Otherwise the LED will burn.
The LED can be connected in a few ways.
• Either the Arduino pin (pin 13 in this case) SOURCES 5v to the LED: the LED’s + pin is connected to the Arduino pin. The LED’s – pin is connected to GND.
• Or the Arduino pin SINKS the circuit through the LED. The LED’s + pin is connected to +5 volt supply. The LED’s – pin is connected to Arduino pin 13.
Code
int ledPin = 13; void setup() { pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, HIGH); delay(1000); digitalWrite(ledPin, LOW); delay(1000); }