How do you plan to solve it?
First, I will build the circuit based on the given diagram. The GPIO pin of the microcontroller will be connected to the positive side (anode) of the LED. A resistor will be added in series to limit the current, and the negative side (cathode) of the LED will be connected to ground.
To find the resistor value, I used Ohm’s Law: V = I × R, which means R = V ÷ I.
The GPIO outputs 5V.
A red LED has a forward voltage drop of about 2V.
So, the resistor will drop the remaining voltage: 5V − 2V = 3V.
I want the LED current to be about 10 mA (0.01 A).
Now, R = 3V ÷ 0.01A = 300 Ω. Since 300 Ω is not always available, I will use the nearest standard value, 330 Ω, which will slightly reduce the current but still allow the LED to light up safely.
/*Paste your code here*/
// Define the pin where the LED is connected
const int ledPin = 13; // Using pin 13, which has a built-in LED on many Arduino boards
void setup() {
// Initialize the digital pin as an output.
pinMode(ledPin, OUTPUT);
}
void loop() {
// Turn the LED on (HIGH is the voltage level)
digitalWrite(ledPin, HIGH);
// Wait for 400 milliseconds
delay(400);
// Turn the LED off by making the voltage LOW
digitalWrite(ledPin, LOW);
// Wait for 800 milliseconds
delay(800);
}
Add video of the output (know more)
Add a photo of your hardware showing the output.