Arduino GPIO LED Blink

KamaliSethurajan
KamaliSethurajan

Solving Approach

How do you plan to solve it?

 Step 1: Select a GPIO Pin

  • Choose a digital pin from the Arduino UNO (e.g., D3) to control the LED.

Step 2: Connect the LED Circuit

  • Connect the anode (long leg) of the LED to the GPIO pin through a 330Ω resistor.
  • Connect the cathode (short leg) of the LED to GND.
  • This setup ensures about 10 mA current through the LED (using Ohm’s Law).

Step 3: Set GPIO as OUTPUT

  • In the setup() function, use pinMode(led, OUTPUT); to configure the selected pin for output mode.

Step 4: Blink the LED

  • Use digitalWrite() inside the loop() to toggle the LED state.
  • LED ON for 400 millisecondsdigitalWrite(led, HIGH);
  • LED OFF for 800 millisecondsdigitalWrite(led, LOW);
  • This timing is controlled using the delay() function.

Step 5: Upload and Test

  • Upload the code to the Arduino UNO.
  • Verify that the LED blinks with the correct timing and brightness.

 

 

 

 

Code

/*Paste your code here*/
int led=3;
void setup(){
pinMode(led,OUTPUT);
Serial.begin(9600);
}
void loop(){
digitalWrite(led,HIGH);
delay(400);
digitalWrite(led,LOW);
delay(800);
}


 

 

 

Output

Video

Add video of the output (know more)

 

 

Photo of Output

 

 

 

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!