Exercise: Blink Built-In LED on UNO


Description: In this exercise, you will write a simple C program to control the built-in LED on the Arduino Uno. This is a common introductory project for beginners to get familiar with the basics of programming and interfacing with hardware. The program will make the built-in LED blink on and off at regular intervals, demonstrating how to control digital outputs on the Arduino.

Difficulty Level

Beginner

Estimated Duration

0:30:00

Prerequisites

No prerequisites have been identified for this exercise.

Resources

  • Computer: A desktop or laptop computer used by developers for writing, compiling, testing, and debugging code. It runs IDEs and supports various programming languages.
  • Monitor: Visual output devices for displaying information, data, or images, including LED, LCD, and OLED screens.
  • Arduino Uno: An open-source microcontroller board based on the ATmega328P chip. It is used for electronics prototyping and programming in educational and hobbyist projects.

Blink Built-In LED on UNO

Introduction

In this exercise, you will learn how to write a simple C program to control the built-in LED on the Arduino Uno. This is a common introductory project that helps beginners get familiar with basic programming and interfacing with hardware. The program will make the built-in LED blink on and off at regular intervals, showcasing how to control digital outputs on the Arduino.

Objectives

By the end of this exercise, you will: - Understand how to write a basic C program for an Arduino. - Learn how to control digital output pins on the Arduino Uno. - Gain hands-on experience in uploading and running programs on the Arduino platform. - Understand the basic concepts of embedded programming.

Materials

To complete this exercise, you will need: - Computer: A desktop or laptop for writing, compiling, testing, and debugging code. - Monitor: A display to visualize the Arduino IDE and observe program outputs. - Arduino Uno: The microcontroller board used for running the program and controlling the hardware.

Preparation Steps

  1. Install the Arduino IDE on your computer if it's not already installed.
  2. Connect your Arduino Uno to the computer via a USB cable.
  3. Launch the Arduino IDE and ensure the correct board and port are selected:
    • Go to Tools > Board > Arduino Uno.
    • Go to Tools > Port and select the appropriate port for your Arduino.
  4. Open the Arduino IDE and start a new sketch (program).

Execution Steps

  1. In the Arduino IDE, write the following code:

    void setup() {
      pinMode(LED_BUILTIN, OUTPUT); // Initialize the built-in LED pin as an output
    }
    
    void loop() {
      digitalWrite(LED_BUILTIN, HIGH); // Turn the LED on
      delay(1000); // Wait for 1 second (1000 milliseconds)
      digitalWrite(LED_BUILTIN, LOW); // Turn the LED off
      delay(1000); // Wait for 1 second (1000 milliseconds)
    }
    
  2. Click the Upload button (right arrow) in the Arduino IDE to compile and upload the program to the Arduino Uno.

  3. Once uploaded, you should see the built-in LED on the Arduino Uno blink on and off every second.

Further Reading

For further study, you can explore the following resources: - Arduino Official Website – A comprehensive resource for everything Arduino. - Arduino IDE Documentation – Learn more about using the Arduino IDE. - Introduction to C Programming for Arduino – A beginner's guide to programming in C for Arduino.