Learn electronics, coding, and projects — step by step.

Arduino Basics: Blink

George Bantique October 4, 2025 No Comments

What is the first sketch to try?

The first program most beginners try is the Blink sketch. It demonstrates how to control a digital output pin by turning the onboard LED on and off at regular intervals.

How do I load the Blink example?

In the Arduino IDE, go to File → Examples → 01.Basics → Blink. This will open the Blink sketch in a new window or just copy the following:

/*
  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://docs.arduino.cc/hardware/

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  https://docs.arduino.cc/built-in-examples/basics/Blink/
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

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

How do I upload the sketch?

Connect your Arduino board to your computer using a USB cable. Then select the correct board and COM port under Tools, click Upload, and wait for the LED to start blinking.

How can I change the blink speed?

In the code, the delay() function controls how long the LED stays on or off. The number inside delay() is in milliseconds (1000 = 1 second).

delay(1000); // LED on or off for 1 second

Try using smaller values like delay(200) for a faster blink or larger ones for a slower effect.

×

Leave a Reply

Required fields are marked *






Related Articles: (by Categories)