top of page

Understanding Your First Arduino Sketch: The LED Blink Tutorial

Arduino is a fun and beginner-friendly way to dive into the world of electronics and coding. It’s a small, affordable device that you can program to perform various cool functions, such as blinking lights, sensing motion, or even building your own robot starting with this LED Blink Tutorial. What makes Arduino great is how easy it is to get started, even if you’ve never written a line of code before. Learning how it works teaches you the basics of programming and how everyday tech around you actually functions. Plus, it’s a great way to boost your creativity and confidence as you bring your ideas to life, one project at a time.


To make things even easier, we’ll be using Tinkercad, a free online tool that allows you to build and simulate Arduino projects directly in your browser—no hardware required! It’s perfect for beginners and a great way to practice without worrying about wires or parts. You can check it out and create a free account here: https://www.tinkercad.com.


Components You'll Need in Tinkercad:

  • 1 x Arduino Uno

  • 1 x LED

  • 1 x 1 KΩ resistor (to prevent burning the LED)

  • Breadboard (optional, but neater)

  • Jumper wires (Choose RED for LIVE and Black for Ground)


Wiring Instructions for your LED Blinking Tutorial


If using the breadboard:


  1. Connect LED:

    • Place the LED on the breadboard.

    • The long leg (anode) goes to a row that you will connect to digital pin 13 on the Arduino.

    • The short leg (cathode) is connected to a separate row that will be connected to ground (GND).


  2. Add Resistor:

    • Place a 1kΩ resistor between the LED’s anode leg and the row going to pin 13.


  3. Wire it up:

    • Connect pin 13 on the Arduino to the row with the resistor.

    • Connect the GND on the Arduino to the cathode row.



      Circuit diagram illustrating the setup for a blinking LED using an Arduino Uno
      Circuit diagram illustrating the setup for a blinking LED using an Arduino Uno connected to a breadboard, highlighting the wiring and components involved in the project.



Code for Blinking LED


// Define the pin where the LED is connected

const int ledPin = 13; // Most Arduino Unos have an onboard LED at pin 13


void setup() {

// Set the LED pin as an output

pinMode(ledPin, OUTPUT);

}

void loop() {

// Turn the LED on

digitalWrite(ledPin, HIGH);

delay(500); // Wait for 500 milliseconds


// Turn the LED off

digitalWrite(ledPin, LOW);

delay(500); // Wait for 500 milliseconds

}



Understanding the Code


// Define the pin where the LED is connected

const int ledPin = 13; // Most Arduino Unos have an onboard LED at pin 13



const int ledPin = 13;


  • You're creating a variable called ledPin and assigning it the value 13, which is the digital pin on the Arduino where the LED is connected.

  • The keyword const means that this number will not change throughout the program.

  • Pin 13 is special because most Arduino Uno boards already have a small built-in LED connected to it.



void setup() {


  • This starts the setup function.

  • Setup () runs once when the Arduino is powered on or reset.

  • It’s where you prepare things before the main loop starts.



// Set the LED pin as an output

pinMode(ledPin, OUTPUT);

}


  • pinMode() instructs the Arduino on the intended function of a pin.

  • Here, pinMode(ledPin, OUTPUT) tells pin 13 to send out electricity, which is what we want to do to turn on the LED.

  • } = Closes the setup() function to end the command.



void loop() {


  • This begins the loop function.

  • loop () is the heart of every Arduino sketch. It runs endlessly, like a repeating playlist.




// Turn the LED on

digitalWrite(ledPin, HIGH);

delay(500); // Wait for 500 milliseconds


  • digitalWrite() is used to send power to a pin.

  • HIGH means “turn it ON” or “send voltage” to that pin.

  • So this line turns the LED on.


  • delay(500) pauses the program for 500 milliseconds, or half a second.

    • The LED stays on during this time.



// Turn the LED off

digitalWrite(ledPin, LOW);

delay(500); // Wait for 500 milliseconds

}


  • Now we're telling the pin to go LOW, which means "turn it OFF" (no power sent). This turns the LED off.

  • Wait another half second with the LED off.


  • } = Ends the loop() function, but since loop() runs forever, it starts again from the top.

Kommentare

Mit 0 von 5 Sternen bewertet.
Noch keine Ratings

Rating hinzufügen

©2025 by Sigma Unlimited . Proudly created with Wix.com

bottom of page