In this article, we will see how to take your first steps with the Arduino UNO development board building a simple project from scratch.

What is Arduino?

Logo Arduino

Arduino designs, creates and supports electronics devices and software that make it easy for people to create their own projects.

Arduino offers various development boards that allow you to build a low-cost prototype.

Many people find it hard to believe, but Arduino was born in Italy (more precisely in Ivrea). If you want to learn more about how the project was born, I recommend watching this video, and to discover all the products offered by Arduino, visit their official website https://www.arduino.cc/.

The Arduino UNO board

The most well-known board is the Arduino UNO:

SchedaArduino UNO
Arduino UNO board – fonte arduino.cc

The Arduino UNO board is based on the ATmega328P microcontroller. It has 14 digital pins (6 of which can be used as PWM outputs) that can be used as inputs and outputs, and another 6 analog pins that can also be used as inputs and outputs.

Shopping bag

black computer compenent
Photo by Pixabay on Pexels.com

To start with Arduino, you have two options:

  1. Use the free online simulator Tinkercad by Autodesk, accessible at this link https://www.tinkercad.com/
  2. Buy an Arduino kit from the official website (https://www.arduino.cc/en/hardware#kits) and experiment with projects by hand.

How to create a project with an Arduino board?

Creating a project using an Arduino board always consists of two steps:

  1. Building the electronic circuit
  2. Writing a program to upload to the Arduino board
Arduino - Scheda con Breadboard
Arduino – board with Breadboard

When you build the circuit, you use a breadboard, the Arduino board, electronic devices, and jumper wires to connect everything together (if you are using Tinkercad, you’ll simulate the same process).

close up photo of matrix background
Photo by Markus Spiske on Pexels.com

In the second step, you write a program in Wiring language (don’t be intimidated, it’s very similar to C) and upload it to the Arduino board using the free Arduino IDE software (https://www.arduino.cc/en/software) by connecting the development board to your computer via USB (with Tinkercad, you write the program directly and start the simulation).

Basic Use of the Tinkercad Interface

Before we proceed with our first project, let’s briefly see how the Tinkercad interface works.

Tip: Even if you have an Arduino kit, it’s always convenient to create your projects on Tinkercad and have them easily accessible.

After registering or logging in (register as a student or personal account) at https://www.tinkercad.com/, the home page of your profile will open:

Home Tinkercad
Home Tinkercad – fonte tinkercad.com

Here you will find a list of all your projects. To create a new one, click the “+ New” button and select the “Circuit” option. At this point, the work area will open, where you can start creating your project by adding components, connecting them, and programming.

Circuito elettronico su Tinkercad
Electronic Circuit on Tinkercad – source tinkercad.com

On the left, you can place the electronic components to be tested, which you search for and select from the right column.

To test a circuit with Arduino, in the search bar in the right column, you must type “Arduino”, select the Arduino already connected to the breadboard, and place it in the empty space on the left:

Arduino e Breadboard su Tinkercad
Arduino and Breadboard on Tinkercad – source tinkercad.com

At this point, you will be able to select other electronic components, place them on the breadboard, and connect them through cables that you can draw by clicking on the breadboard holes.

My first project with Arduino: a blinking LED

The first project to get familiar with Arduino is a blinking LED.

Phase 1: Creating the electronic circuit

Shopping bag:

  • Arduino Uno board
  • USB cable
  • Breadboard
  • A resistor with a value between 220 Ω and 1 kΩ
  • An LED of your choice (red, green, yellow, or blue)
  • Jumper cables to make connections

The electrical scheme to be realized is the following:

Schema elettrico funzionale led che lampeggia con Arduino
Functional electrical diagram of blinking LED – source arduino.cc

As seen from the functional diagram, the resistor must be connected to Arduino pin 13, after the resistor, the anode of our LED (the + part, the longest LED leg) is connected, and finally, the cathode of the LED (the – part, the shortest LED leg) is connected to ground at the GND pin of the Arduino.

Schema elettrico di montaggio led che lampeggia con Arduino
Assembly electrical diagram of flashing LED – source arduino.cc

Phase 2: Writing and uploading the program

Before getting into the details of the project, let’s see how an Arduino program is structured.

Structure of an Arduino program

An Arduino program (called a sketch) consists of 3 main parts:

#include "nameOfTheLibrary.h"

void setup(){
//initial steps
}

void loop(){
//part of the program that will be repeated endlessly
}

Just like in the C language, I can call external libraries and define variables that I will use in the program.

The setup() function is the part of the program that is executed ONLY once at startup and serves to define the initial operations that the program must perform (initialization) and to define the purpose of the Arduino pins that I will use (if in read or write mode).

The loop() function is the hot part of the program that will be repeated endlessly (from when I turn on the board until I turn it off).

Fundamental functions to use in an Arduino sketch

Before getting into the code, you always need to identify the Arduino pins you will use and define their mode. In the case of the blinking LED, we will use the digital pin 13 of Arduino in write mode (OUTPUT), as we will turn on (high signal, HIGH) and turn off (low signal, LOW) the LED.

To define the mode of a pin we use the pinMode() function:

pinMode(pinNumber,mode);

//Example:if I use pin 13 for reading (INPUT)
pinMode(13,INPUT);

//Example: if I use pin 13 for writing (OUTPUT)
pinMode(13,OUTPUT);

To write a digital value (HIGH or LOW) on a pin, the digitalWrite() function is used:

digitalWrite(pinNumber,value);

//Example: if I want to write an HIGH value on pin 13
digitalWrite(13,HIGH);

//Example: if I want to write a LOW value on pin 13
digitalWrite(13,LOW);

To make our LED blink, we use a delay function called delay():

delay(valueInMilliseconds);

//Example: if I want to wait 1s
delay(1000);

Full code of our first program

After all these examples, here is the complete code of our first project to make the LED blink every second:

void setup(){
  pinMode(13,OUTPUT);
}

void loop(){
  digitalWrite(13,HIGH);
  delay(1000);
  digitalWrite(13,LOW);
  delay(1000);
}

Test on Tinkercad

To test the program on Tinkercad, proceed as follows:

1) Click on the “Code” button on the top right and click on the “text” option. In the message that appears, click on “Continue”. If you did everything right, a window will open where you can enter the code to program the Arduino board.

Come inserire il codice per programmare Arduino su Tinkercad
How to enter the code to program Arduino on Tinkercad

2) Once you have copied the code, you can test my project by pressing the “Start simulation” button (next to “Code”).

Here is the final project created on Tinkercad:

Progetto su Tinkercad: led che lampeggia
Project on Tinkercad: flashing LED

Test with Arduino kit

To test it using the kit, proceed as follows:

1) Download, install and launch the Arduino IDE program (download link: https://www.arduino.cc/en/software):

Arduino IDE interfaccia
Arduino IDE interface

2) Copy the code to the Arduino IDE program:

Programma copiato su Arduino IDE
Program copied to Arduino IDE

3) Connect the Arduino board to the PC via the USB cable.

4) Click on “Select Board” and select the USB port to which the Arduino board is connected:

Seleziona scheda su Arduino IDE
Select board on Arduino IDE

5) Press “Upload” to upload the program to the board:

Caricamento programma su scheda Arduino da programma IDE
Program upload to Arduino board from IDE program

6) If the upload is successful, no message will appear in the terminal. If not, the errors to be corrected in the code will appear in red:

Esempio di caricamento andato a buon fine sulla scheda Arduino dal programma Arduino IDE
Example of successful upload to the Arduino board from the Arduino IDE program
Esempio di caricamento non andato a buon fine sulla scheda Arduino dal programma Arduino IDE
Example of unsuccessful upload due to an error in the code

Congratulations! You have created your first Arduino project from scratch 🎉🎉🎉