Example Code for Arduino-Blink LED

This article provides an example code for blinking an LED using Arduino, including detailed hardware preparation, software setup, and a wiring diagram to assist beginners in understanding the process.

Hardware Preparation

  • UNO x1
  • Bright LED Module x1
  • Some wires

Software Preparation

Wiring Diagram

DFR0438 Gravity: Bright LED Module Connection Diagram

Sample Code

void setup() {
  // initialize digital pin 13 as an output.
   pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);    // turn the LED on (HIGH is the voltage level)
   delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

Result

This simple sample code will turn on and off this LED module every one second. And the brightness is depend on the voltage it gets from Arduino. (Maximum is 5V.)

Was this article helpful?

TOP