Example Code for Arduino-LED Blink

Last revision 2025/11/29

This article provides a detailed guide on creating an LED blink project using Arduino, covering hardware setup, software requirements, wiring instructions, and sample code to help beginners understand basic Arduino operations.

Hardware Preparation

Software Preparation

  • Development Tool: Arduino IDE (version unspecified). Download link: Arduino IDE

Wiring Diagram

Digital module connection diagram

Sample Code

///Arduino Sample Code for DFR0021
///www.DFRobot.com
///Last modified on 26th February 2015

int led = 3;

void setup()
{
  pinMode(led, OUTPUT);     //Set Pin3 as output
}
void loop()
{
          digitalWrite(led, HIGH);   //Turn on led
          delay(2000);
          digitalWrite(led, LOW);    //Turn off led
          delay(2000);
}

Result

Turn on for two seconds, turn off for two seconds, and repeat in a loop.

Was this article helpful?

TOP