The Arduino gives 5 volts. The LED only needs about 2 volts. That means the extra 3 volts must drop across the resistor. If we want around 10 mA of current, we divide 3 volts by 0.01 amps. Since 300 Ω is not a common resistor value, we use 330 Ω, which is close. This makes the LED current about 10 mA, which is safe for the LED.
void setup() {
pinMode(12, OUTPUT);
}
void loop() {
digitalWrite(12, HIGH); // LED ON
delay(400);
digitalWrite(12, LOW); // LED OFF
delay(800);
}
Add video of the output (know more)