Ex. 13 Introduction to Arduino and Programming
Ex. 13 Introduction to Arduino and Programming
AIM:
To study the basics of Arduino Uno board and Arduino IDE 2.0 software.
INTRODUCTION TO ARDUINO:
Arduino is a project, open-source hardware, and software platform used to design and build electronic
devices. It designs and manufactures microcontroller kits and single-board interfaces for building
electronics projects. The Arduino boards re initially created to help students with the non-technical
background. The designs of Arduino boards use a variety of controllers and microprocessors.
Arduino is an easy-to-use open platform for creating electronic projects. Arduino boards play a vital
role in creating different projects. It makes electronics accessible to non-engineers, hobbyists, etc.
The various components present on the Arduino boards are a Microcontroller, Digital Input/output
pins, USB Interface and Connector, Analog Pins, reset buttons, Po r buttons, LEDs, Crystal
oscillators, and Voltage regulators. Some components may differ depending on the type of board.
The most standard and popular board used over time is Arduino UNO. The ATmega328
Microcontroller present on the UNO board makes it rather po rful than other boards. There are
various types of Arduino boards used for different purposes and projects. The Arduino Boards are
organized using the Arduino (IDE), which can run on various platforms. Here, IDE stands for
Integrated Development Environment. Let's discuss some common and best Arduino boards.
TYPES OF ARDUINO BOARDS
1) Arduino UNO
Arduino UNO is based on an ATmega328P microcontroller. It is easy to use compared to other
boards, such as the Arduino Mega board, etc. The Arduino UNO includes 6 analog pin inputs, 14
digital pins, a USB connector, a po r jack, and an ICSP (In-Circuit Serial Programming) header. It is
the most used and of standard form from the list of all available Arduino Boards.
2) Arduino Nano
The Arduino Nano is a small Arduino board based on ATmega328P or ATmega628 Microcontroller.
The connectivity is the same as the Arduino UNO board. The Nano board is defined as a sustainable,
small, consistent, and flexible microcontroller board. It is small in size compared to the UNO board.
The devices required to start our projects using the Arduino Nano board are Arduino IDE and mini-
USB. The Arduino Nano includes an I/O pin set of 14 digital pins and 8 analog pins. It also includes
6 Po r pins and 2 Reset pins.
3) Arduino Mega
The Arduino Mega is based on the ATmega2560 Microcontroller. The ATmega2560 is an 8-bit
microcontroller. need a simple USB cable to connect to the computer and the AC to DC adapter or
battery to get started with it. It has the advantage of working with more memory space. The
Arduino Mega includes 54 I/O digital pins and 16 Analog Input/Output (I/O), ICSP header, a reset
button, 4 UART (Universal Asynchronous Reciever/Transmitter) ports, USB connection, and a po r
jack.
4) Arduino Micro
The Arduino Micro is based on the ATmega32U4 Microcontroller. It consists of 20 sets of pins. The
7 pins from the set are PWM (Pulse Width Modulation) pins, while 12 pins are analog input pins.
The other components on board are a reset button, a 16MHz crystal oscillator, an ICSP header, and
a micro-USB connection. The USB is built in the Arduino Micro board.
5) Arduino Leonardo
The basic specification of the Arduino Leonardo is the same as the Arduino Micro. It is also based
on the ATmega32U4 Microcontroller. The components present on the board are 20 analog and digital
pins, a reset button, a 16MHz crystal oscillator, an ICSP header, and a micro USB connection.
6) Arduino Due
The Arduino Due is based on the 32-bit ARM core. It is the first Arduino board that has been
developed based on the ARM Microcontroller. It consists of 54 Digital Input/Output pins and 12
Analog pins. The Microcontroller present on the board is the Atmel SAM3X8E ARM Cortex-M3
CPU. It has two ports, namely, a native USB port and a Programming port. The micro side of the
USB cable should be attached to the programming port.
7) Arduino Lilypad
The Arduino LilyPad was initially created for arable projects and e-textiles. It is based on the
ATmega168 Microcontroller. The functionality of Lilypad is the same as other Arduino Boards. It is
a round, light ight board with a minimal number of components to keep the size of the board small.
The Arduino Lilypad board was designed by Sparkfun and Leah. It was developed by Leah Buechley.
It has 9 digital I/O pins.
8) Arduino Bluetooth
The Arduino Bluetooth board is based on ATmega168 Microcontroller. It is also named as Arduino
BT board. The components present on the board are 16 digital pins, 6 analog pins, reset button,
16MHz crystal oscillator, ICSP header, and screw terminals. The screw terminals are used for po r.
The Arduino Bluetooth Microcontroller board can be programmed over the Bluetooth as a wireless
connection.
9) Arduino Diecimila
The Arduino Diecimila is also based on the ATmeg628 Microcontroller. The board consists of 6
analog pin inputs, 14 digital Input/Output pins, a USB connector, a po r jack, an ICSP (In-Circuit
Serial Programming) header, and a reset button. can connect the board to the computer using the
USB and can po r on the board with the help of an AC to DC adapter. The Diecimila was initially
developed to mark the 10000 delivered boards of Arduino. Here, Diecimila means 10,000 in Italian.
SDA: It stands for Serial Data. It is a line used by the slave and master to send and receive data. It
is called as a data line, while SCL is called as a clock line.
SCL: It stands for Serial Clock. It is defined as the line that carries the clock data. It is used to
synchronize the transfer of data bet en the two devices. The Serial Clock is generated by the device
and it is called as master.
SPI: It stands for Serial Peripheral Interface. It is popularly used by the microcontrollers to
communicate with one or more peripheral devices quickly. It uses conductors for data receiving,
data sending, synchronization, and device selection (for communication).
MOSI: It stands for Master Output/ Slave Input. The MOSI and SCK are driven by the Master.
SS: It stands for Slave Select. It is the Slave Select line, which is used by the master. It acts as the
enable line. I2C: It is the two-wire serial communication protocol. It stands for Inter Integrated
Circuits. The I2C is a serial communication protocol that uses SCL (Serial Clock) and SDA (Serial
Data) to receive and send data bet en two devices. 3.3V and 5V are the operating voltages of the
board.
The Arduino IDE 2.0 is an open-source project, currently in its beta-phase. It is a big step from it's
sturdy predecessor, Arduino IDE 2.0, and comes with revamped UI, improved board & library
manger, autocomplete feature and much more.
In this tutorial, will go through step by step, how to download and install the software.
Download the editor
Downloading the Arduino IDE 2.0 is done through the Arduino Software page. Here will also
find information on the other editors available to use.
Requirements
Windows - Win 10 and ne r, 64 bits
Linux - 64 bits
Mac OS X - Version 10.14: "Mojave" or ne r, 64 bits
Installation
Windows
Download URL: https://www.arduino.cc/en/software
To install the Arduino IDE 2.0 on a Windows computer, simply run the file downloaded from the
software page.
Follow the instructions in the installation guide. The installation may take several minutes.
How to use the board manager with the Arduino IDE 2.0
The board manager is a great tool for installing the necessary cores to use the Arduino boards. In
this quick tutorial, will take a look at how to install one, and choosing the right core for the board!
Requirements
Arduino IDE 2.0 installed.
Why use the board manager?
The board manager is a tool that is used to install different cores on the local computer. A core is
written and designed for specific microcontrollers. As Arduino have several different types of
boards, they also have different type of microcontrollers.
For example, an Arduino UNO has an ATmega328P, which uses the AVR core, while an Arduino
Nano 33 IoT has a SAMD21 microcontroller, where need to use the SAMD core.
In conclusion, to use a specific board, need to install a specific core.
Installing a core
Installing a core is quick and easy, but let's take a look at what need to do.
1. Open the Arduino IDE 2.0.
2. With the editor open, let's take a look at the left column. Here, can see a couple of icons.
Let's click the on the "computer chip" icon.
1. A list will now appear of all available cores. Now let's say are using an Nano 33
IoT board, and want to install the core. Simply enter the name in the search field, and the
right core (SAMD) will appear, where the Nano 33 IoT features in the description. Click on
the "INSTALL" button.
4. This will begin an installation process, which in some cases may take several minutes.
5. When it is finished, can take a look at the core in the boards manager column, where it
should say "INSTALLED".
How to upload a sketch with the Arduino IDE 2.0
In the Arduino environment, write sketches that can be uploaded to Arduino boards. In this
tutorial, will go through how to select a board connected to the computer, and how to upload a
sketch to that board, using the Arduino IDE 2.0.
Requirements
Arduino IDE 2.0 installed.
Verify VS Upload
There are two main tools when uploading a sketch to a board: verify and upload. The verify tool
simply goes through the sketch, checks for errors and compiles it. The upload tool does the same,
but when it finishes compiling the code, it also uploads it to the board.
A good practice is to use the verifying tool before attempting to upload anything. This is a quick
way of spotting any errors in the code, so can fix them before actually uploading the code.
Uploading a sketch
Installing a core is quick and easy, but let's take a look at what need to do.
1. Open the Arduino IDE 2.0.
2. With the editor open, let's take a look at the navigation bar at the top. At the very left, there
is a checkmark and an arrow pointing right. The checkmark is used to verify, and the
arrow is used to upload.
3. Click on the verify tool (checkmark). Since are verifying an empty sketch, can be sure it is
going to compile. After a few seconds, can see the result of the action in the console (black
box in the bottom).
1. Now know that our code is compiled, and that it is working. Now, before can upload the
code to our board, will first need to select the board that are using. can do this by
navigating to Tools > Port > {Board}. The board(s) that are connected to the computer
should appear here, and need to select it by clicking it. In this case, our board is displayed as
COM44 (Arduino UNO).
5. With the board selected, are good to go! Click on the upload button, and it will start
uploading the sketch to the board.
6. When it is finished, it will notify in the console log. Of course, sometimes there are some
complications when uploading, and these errors will be listed here as ll.
How to install and use a library with the Arduino IDE 2.0
A large part of the Arduino programming experience is the use of libraries. Thousands of libraries
can be found online, and the best-documented ones can be found and installed directly through the
editor.
Requirements
Arduino IDE 2.0 installed.
Why use libraries?
Libraries are incredibly useful when creating a project of any type. They make our development
experience much smoother, and there almost an infinite amount out there. They are used to interface
with many different sensors, RTCs, Wi-Fi modules, RGB matrices and of course with other
components on the board.
Arduino has many official libraries, but the real heroes are the Arduino community, who develop,
maintain and improve their libraries on a regular basis.
Installing a library
Installing a library is quick and easy, but let's take a look at what need to do.
1. Open the Arduino IDE 2.0.
2. With the editor open, let's take a look at the left column. Here, can see a couple of icons.
Let's click the on the "library" icon.
3. A list will now appear of all available libraries, where can also search for the library want
to use. In this example, are going to install the RTCZero library. Click on the
"INSTALL" button to install the library.
4. This process should not take too long, but allow up to a minute to install it.
5. When it is finished, can take a look at the library in the library manager column, where it should
say "INSTALLED".
Including a library
To use a library, first need to include the library at the top of the sketch.
Almost all libraries come with already made examples that can use. These are accessible through
File > Examples > {Library} > {Example}. In this example, are choosing the
RTCZero > SimpleRTC.
The chosen example will now open up in a new window, and can start using it hover.
Conclusion
In conclusion, this detailed introduction to the Arduino platform and programming provides a
clear foundation for understanding its components, functionalities, and applications. From its
versatile hardware and intuitive software to its beginner-friendly programming structure, Arduino
empowers users to innovate across various fields like robotics, IoT, and automation.
The explanation offered not only highlights the practical aspects of Arduino but also
underscores its significance in modern technology and education. With its open-source nature and
robust community support, Arduino continues to inspire creativity and problem-solving, making it an
essential tool for both novices and experts in embedded systems development.