[go: up one dir, main page]

0% found this document useful (0 votes)
10 views24 pages

assignment 3

Arduino is an open-source platform that combines hardware and software for easy use in hobby projects and prototyping, allowing users to control devices and read sensors. It features a variety of boards, such as the Arduino Uno and Nano, which cater to different applications and processing needs, and utilizes a simplified programming environment. The platform is designed to be accessible for beginners while also offering advanced capabilities for experienced users.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views24 pages

assignment 3

Arduino is an open-source platform that combines hardware and software for easy use in hobby projects and prototyping, allowing users to control devices and read sensors. It features a variety of boards, such as the Arduino Uno and Nano, which cater to different applications and processing needs, and utilizes a simplified programming environment. The platform is designed to be accessible for beginners while also offering advanced capabilities for experienced users.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

andArduino Programming

JOT
3.17
AINTRODUCTION TO ARDUINO
34.
WhatisArduino?

Arduino platform offers open source


used widely for hobby
hardware and software that is easy to use and
is
is projects and prototyping. An
Uatrollerlike
development board. we can use the Arduino is an
open-souree
controlthings motors and lights. This allows us to Arduino to read sensors and
whichcan
then interact with things in the real upload programs to this board
respond and react to the world, With this, we can make devices
which world at
large.
Arduino is a prototype
platform (open-source) based on an
and softvware. It consists of a
circuit board, easy-to-use
which can be programed
hardware
microcontroller) and a (referred to as a
ready-made software called Arduino IDE (Integrated
Developmnent Environment), which is used to
thephysical board.
write and upload the computer code to
OpenSource?
when it is said that Arduino is an
open source platform, it means that all
taformation regarding the hardware and software that the
oioilable and can be used by anyone. They provide the Arduino provides is freely
and software which can be used by designs for their hardware
anyone. Anyone can use
manufacture the hardware and can distribute the software, no licensesthese designs to
are required.
Why Arduino?
Arduino provides many types of boards which are useful for
various
applications. Arduino also provides its own IDE (Integrated Development
Environment) which is free to download from Arduino's website and use.
Many libraries are provided with the software and a large number of
libraries developed by people from around the world are available for free.
The functions implemented in these libraries can be used for quick
development purposes.
This allows the user to use certain interfaces or modules without having in
depth knowledge about the internal structure or working.
The point is that lack of technicalor coding knowledge should not become
an obstacle for development or creative thinking.
3.18 Embedded Systems and IOr
They also offer a number of expansion boards (or shields as they cal
them) which can be plugged into their boards and used. All of
enable fast and easy development.
these
3.4.1. THE KEY FEATURES ARE
Arduino boards are able to read analog or digital input signals fron
different sensors and turn it into an output such as activating a motor,
turning LED on/off, connect to the cloud and many other actions.
We can control our board functions by sending a set of instructions tothe
microcontroller on the board via Arduino IDE (referred to as
software).
uploading
Unlikemost previous programmable circuit boards, Arduino does not need
an extra piece of hardware (called a programmer) in order to load a new
code onto the board. we can simply use a USB cable.
Additionally, the Arduino IDE uses a simplified version of C++, making it
easier to learn to program.
Finally, Arduino provides a standard form factor that breaks the functions
of the microcontroller into a more accessible package.
3.4.2. ARDUINO BOARDS
A wide range of boards is manufactured by Arduino. These have different sizes.
different microcontrollers, and different processing capabilities. There are entry level
boards like the UNO, LEONARD0, NANO etc; boards ith enhanced feature like
the MEGA, PRO, ZER0 etc; boards for Internet of Things like the YUN, TIAN etc:
and wearable boards like the LILYPAD, GEMMA etc. Depending on the need of
application and the processing requirements, users can choose from any of these.
There are many varieties of Arduino boards that can be used for different
purposes. Some boards look a bit different from the one below, but most Arduinos
have the majority of these components in common:
Power (USB/Barrel Jack)
Every Arduino board needs a way to be connected to a power source. The
Arduino UNO can be powered from a USB cable coming from our computer or a
wall power supply that is terminated in a barrel jack. In the picture above the USB
JOTand
dArduino Programming 3.19|

connectionis labeled (1) and the barrel jack is labeled (2).The USB connection is
we wilIload code onto our Arduino board. Do NOT
alsohoW use a power supply
greaterthan 20 Volts as we will overpower (and thereby destroy) our Arduino. The
recommended voltage for most
Arduino models is between 6 and 12 Volts.
10 Z/8~

OxGITAL M 11
O(UNO)
RDUTNO

SPKI8.Ob0G.

Fig.3.8. Arduino board


Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)
The pins on our Arduino are the places where we connect wires to construct a
citcuit probably in conjunction with abreadboard and some wire.They usually have
black plastic 'headers' that allow us to just plug awire right into the board. The
Arduino has several different kinds of pins, cach of which is labeled on the board and
used for different functions.
GND (3): Short for Ground'. There are several GND pins on the Arduino,
any of which can be used to ground our circuit.
SV (4) & 3.3V (5): As we might guess, the 5V pin supplies 5 volts of
power, and the 3.3V pin supplies 3.3 volts of power. Most of the simple
components used with the Arduino run happily off of 5 or 3.3 volts.
Analog (6): The area of pins under the 'Analog In' label (A0 through AS
on the UNO) are Analog In pins. These pins can read the signal from an
analog sensor (like atemperature sensor)and convert it into a digitalvalue
that we can read.

Digital (7): Across from the analog pins are the digital pins (0 through 13
on the UNO). These pins can be used for both digital input (like telling if a
button is pushed) and digital output (like powering an LED).
3.20 EmbeddedSystems and Ior
PWM (8): we may have noticed the tilde () next to Some of
pins (3, 5, 6, 9, 10, and 11 on the UNO). These pins act as
the igta
normal
pins, but can also be used for something called Pulse-Width digta
(PWM).
AREF (9): Stands for Analog Reference. Most of the time we
Modulation
can
this pin alone. It is sometimes used to set an external reference leave
(between0 and SVolts) as the upper limit for the analog input pins. voltage
Reset Button
Just like the original Nintendo, the Arduino has a reset button (10). Pushing it wil
temporarily connect the reset pin to ground and restart any code that is loaded on .
Arduino. This can be very useful if our code doesn't repeat, but we want to test i:
multiple times. Unlike the original Nintendo however, blowing on the Arduinn
doesn't usually fix any problems.
Power LED Indicator
Just beneath and to the right of the word UNO" on our circuit board, there's a
tiny LED next to the word 'ON' (11). This LED should light up
whenever we plug
our Arduino into a power source. If this light doesn't turn on, there's a good chance
something is wrong. Time to re-check your circuit!
TX RX LEDs
TX is short for transmit, RX is short for receive. These
markings appear quite a
bit in electronics to indicate the pins responsible for serial
communication. In our
case, there are two places on the Arduino UNOwhere TX and RX appear -- once by
digital pins 0 and 1, and a second time next to the TX and RX indicator LEDs (12).
These LEDs will give us some nice visual indications whenever our Arduino is
receiving or transmitting data (like when we're loading a new program onto the
board).
Main iC
The black thing with all the metal legs is an IC, or Integrated Circuit (13). Think
of it as the brains of our Arduino. The main IC on the Arduino is slightly different
from board type to board type, but is usually from the AT mega line ofIC's from the
ATMEL company. This can be important, as we may need to know the IC typ
(along with our board type) before loading up a new program from the Arduo
JOTand Arduino Programming
3.21|
software. This information can usually be found in
f we
want to know more about the writing on the top side ofthe IC.
datasheets is often agood idea. difference between various IC's, reading the
Voltage Regulator
The voltage regulator (14) 1s not
actually something we can (or should) interaeL
with onthe Arduino. But it is
potentially useful to know that it is there and what it's
for. The voltage regulator does exactly what it says -- it controls the amount of
voltage that is let into the Arduino board.
Think of it as a kind of it will
turn away an extra gatekeeper;
voltage that might harm the circuit. Of course, it has its limits, so
don'tt hook up our Arduino to anything greaterthan 20
volts.
3.4.3. FEATURES OF ARDUINO BOARD
The operating voltage is SV
The recommended input voltage will range from 7v
to 12V
The input voltage ranges from 6v to 20V
Digital input/output pins are 14
Analog iip pins are 6
DCCurrent for each input/output pin is 40 mA
DCCurrent for 3.3V Pin is 50 mA
Flash Memory is 32 KB
SRAM is 2 KB
EEPROM is 1 KB
CLK Speed is 16 MHZ

3.5. TYPES OF ARDUINO

Arduino board was designed in the Ivrea Interaction Design Institute intended for
students without a background in electronics and programming concepts. This board
started altering to adapt to new requirementsand challenges, separating its presence
from simple 8-bit boards to products for loT (Internet of Things) applications, 3D
printing, wearable, and embedded surroundings.
Embedded.
3.22 Systems and Ior
All boards are entirely open-source, allowing users to build them
finally adapt them to their exact needs. Over the years the
separat ely
different typeands
of Arduino boards have been used to build thousands of projects, from
to compound scientific instruments. An international community of
daily objecs
designers,
students, programmers, hobbyists, and experts has gotten together around this arotists,
source stage, their donations have added up to an unbelievable amount of
knowledge that can be of immense help to beginners and specialists alike. available
3.5.1. WHAT ARE THE TYPES OF ARDUINO BOARDS?
Arduino board is an open-source platform used to make electronics projects.
consists of both a microcontroller and a part of the software or

Development Environment (IDE) that runs on our PC, used to write and uno Integrated
computer code to the physical board.
Unlike most earlier programmable circuit boards, the Arduino does not require a
separate part of hardware in order to program a new code onto the board we can iue
use a USB cable. As well, the Arduino IDE uses a basic version of C+t, making i
simpler to learn the program. At last, the Arduino board offers a typical form factor
that breaks out the functions of the microcontroller into a more available package.
Why Arduino Boards?
Arduino board has been used for making different engineering projects and
different applications. The Arduino software is very simple to use for beginners, yet
flexible adequate for advanced users. It runs Windows, Linux, and Mac. There are
numerous other microcontroller platforms obtainable for physical computing. The
Netmedia's BX-24, Parallax Basic Stamp, MIT's Handyboard, Phidget, and many
others present related functionality. Arduino also makes simpler the working process
of microcontroller, but it gives some advantages over other systems
such as
Inexpensive
Cross-platform
The simple, clear programming environment
Open source and extensible software
Open source and extensible hardware
IOTand Arduino
Programming
3.5.2. THE FUNCTION OF THE 3.23
s
fexibility of the
Arduino
ARDUINO BOARD
imagine. This board can be board is enormous so that one
connected can do
obstacle sensors,
presence detectors, fire
very anythingsuchtheyas
easily to different modules
The main function of the sensors, GSM Modules GPS
inputs &changing it into Arduino board is to control modules, etc.
also used to make outputs because this board electronics through reading
robotics, et.
different electronics works like a tool. This toard is
projects in the field of electronics, electrical,
E3. FEATURES OF
The features of DIFFERENT TYPES OF ARDUINO BOARDS
different types of Arduino bo¡rds are
Arduino listed in the tabular form.
Board
Processor Memory Digital Analogue UO
Arduino Uno I/O
16Mhz. 2KB SRAM, 14 6 input, 0 output
ATmega328 32KB flash
Arduino Due 84MHz 96KB SRAM, 54 12 input, 2 output
Arduino Mega
AT91SAM3X8E
16MHz
S12KB flash
8KB SRAM, 54 16 input, 0 output
ATmega2560 256KB flash
Arduino 16MHz
Leonardo 2.5KB SRAM, 20 12 input, 0output
ATmega32u4 32KB flash

3.5.4. DIFFERENT TYPES OF


ARDUINO BOARDS
The list of Arduino boards
includes the following such as
$ Arduino Uno (R3)
Arduino Nano
$ Arduino Micro

Arduino Due
LilyPad Arduino Board
$ Arduino Bluetooth
3.24 Embedded Systems and Iom
Arduino Diecimila
RedBoard ArduinoBoard
Arduino Mega(R3)Board
Arduino Leonardo Board
Arduino Robot
Arduino Esplora
Arduino Pro Mic
Arduino Ethernet
Arduino Zero
Fastest Arduino Board
3.5.4.1. Arduino Uno (R3)
The Uno is a huge option for our initial Arduino. This Arduino board
depends on an ATmega328P based microcontroller. As compared with
other types of Arduino boards, it is very simple to use like the Arduino
Mega type board.
It consists of 14-digital I/Opins, where 6-pins can be used as PWM(pulse
width modulation outputs), 6-analog inputs, a reset button, a power jack, a
USB connection, an In-Circuit Serial Programming header (CSP), etc.

Fig. 3.9. Arduino Uno (R3)


It includes everything required to hold up the microcontroller; simpy
attach it to a PC with the help of a USB cable and give the supply to g
started with an AC-to-DC adapter or battery.
i Arduino
JOTand. Programming 3.25
Arduino Uno is the most frequently used board and it is the standard form
anart from all the existing Arduino Boards. This board is very useful for
beginners.
3.5.4.2. Arduino Nano
This is a small board based on the microcontrollers like ATmegaszor
otherwise ATmega628 but the connection of this board is the same as to
the Arduino UNOboard. This kind of microcontroller board is very small
insize, sustainable, flexible, and reliable.

Fig. 3.10. Arduino Nano


As compared with the Arduino Uno board, it is small in size. The devices
like mini USB and Arduino IDE are necessary to build the projects. This
board mainlyincludes analog pins-8, digital pins-14 with the set of an Vo
pin, power pins-6 & RST (reset) pins-2.
3.5.4.3. Arduino Micro
The Arduino Micro board mainly depends on the ATmega32U4 based
Microcontroller that includes 20-sets of pins where the 7-pins are PWM
pins, 12-analog input pins. This board includes different components like
an ICSP header, RST button, small USB connection, crystal oscillator
16MHz. The USB connection is hbuilt and this board is the shrunk
version of the Leonardo board.

Fig. 3.11. Arduino Micro


3.26
Embedded Systems and Io?
3.5.4.4. Arduino Due

This Arduino board depends on the ARM Cortex-M3 and it is the


Arduino microcontroller board. This board includes digital I/O first
where 12-pins are PWM op pins, analog pins -l2, UART's-4, a CLK pins-54
84 MHZ, an USB OTG, DAC-2, a power jack, TWI-2, a JTAG header
SPI header, two buttons for reset and erase.

Fig. 3.12. Arduino Due


This board works with 3.3V where the highest voltage that the pins of
input/output can stand is 3.3V because providing a high voltage to any VÌ
pin can lead todamage the board.
This board is simply connected to a computer through a small USB cable
otherwise it can be powered through an AC to DC adapter. This Arduino
Due board is suitable with all shields of Arduino at 3.3V.
3.5.4.5. Lily Pad Arduino Board
4 Input pins:
Reset Button a2, a3, a4, a5
FTDIConnector (to
Negative Lead connect to PC)

Battery Connector 9Output pins:


5, 6, 9, 10, 11,
Positive Lead 16, 17, 18, 19

On/ Off Switch


Processor /"brain"

Fig. 3.13. Lily Pad Arduino Boards


ArduinoProgramming 3.27
and
oT
The Lily Pad Arduino board is a wearable e-textile technology expanded
by Leah" Buechley" and considerately designed by "Leah and SparkFun".
Each board was imaginatively designed with huge cconnecting pads & a
smooth back to let them to be sewn into clothing using conductive thread.
This Arduino also comprises of I/O, power, and also sensor boards which
are built especially for e-textiles. These are even washable.
3.5.4.6. Arduino Bluetooth
4 This Bluetooth mainly depends on the microcontroller like ATmegalo3
and this board is also called Arduino BT. This kind of board includes
different components like digital pins-16, analog pins-6, crystal oscillator
16MHZ, reset button,screw terminals, ICSP header.
In this board, the screw terminals are mainly used for power. 1 he
done with
programming of this Bluetooth microcontroller can be
Bluetooth like a wireless connection.
3.5.4.7. Arduino Diecimila
on the
The microcontroller board like Arduino Diecimila mainly depends
ATmegal68. This board includes digital /O pins -14 where 6-pins can be
a crystal
used like PWM outputs & analog inputs-6, a USB connection,
oscillator-16 MHz, an ICSP header, a reset button & a power jack.
cable and it can
This board can be connected to a computer through a USB
be activated using a battery and an AC-DCadapter.

X rduing
RX Diecimila

Fig. 3.14. Arduino Diecimila


Embedded
3.28 Systems and I T
3.5.4.8. Red Board Arduino Board
The Red Board Arduino board can be programmed using a Mini-B USH
cable using the Arduino IDE. It will work on Windows 8 without
modify our security settings. It is more constant due to the USB havior nFTDIg ty
chip we used and also it is entirely flat on the back.
Creating it is very simple to utilize in the project design. Just plug the
board, select the menu option to choose an Arduino UNO and we are
ready
to upload the program. we can control the Red Board over a USB
using the barrel jack.
cable

Fig. 3.15. Red Board Arduino Boards


3.5.4.9. Arduino Mega (R3) Board
The Arduino Mega is similar to the UNO's big brother, It includes lots of
digital VO pins (from that, 14-pins can be used as PWM o/ps), 6-analog
inputs, a reset button, apower jack, a USB connection, and a reset button.

S MEGA)

Fig. 3.16. Arduino Mega (R3) Board


JOTand4Arduino Programming
3.29
It includes everything required to hold up the
attach it to a PC with the help of a USB cable microcontroller;
simply
started with an and give the supply to get
make this ArduinoAC-to-DC adapter or battery. The huge number of pins
board very
bunch of digital /ps or o/pslike helpful
lots of
for designing projects that
need a
3.5.4.10. Arduino
buttons.
Leonardo Board
& The first development board of an
board uses one microcontroller alongArduino
is the Leonardo board. This
with the USB. That means, it can be
very simple and cheap also. Because this
board handles USB directly,
program lhbraries are obtainable which let the Arduino
board to follow a
keyboard of the computer, mouse, etc.

OO LEONARD0
ARDUINO

Fig. 3.17. Arduino Leonardo Board


3.5.4.11. Arduino Robot
This kind of board is the first Arduino over wheels. This Arduino robot
includes two processors on each of its boards. The two boards are the
motor board ánd control board where the motor board controls the motors
and the control board is used to read the sensors for operating.
Every board is a complete Arduino board and its programming can be
done through the Arduino IDE. These are microcontroller boards that
depend on the ATmega32u4. The pins of this Robot are mapped to
actuators and sensors onboard.
The process of programming the robot is the same as the Arduino
Leonardo board. It is also named a small computer and it is extensively
3.30 Embedded. Systems
and IoT
used in robotics. This board includes the speaker, color screen,
but onislo-5or,
motors-2, a digital compass, an SD card reader, potentiometers-2 &
sensors-5. The library of this robot can be used for controlling the
as well as the actuators. sensors
3.5.4.12. Arduino Esplora
The Arduino Esplora includes a small computer known
microcontroller including a number of inputs and outputs. The
this board are a light sensor, four buttons, a microphone, an inputs of
accelerometer,
joystick, a slider, a temperature sensor, etc whereas the outputs are .
color LED, a buzzer. This kind of Arduino board looks like
controller. videogame

Fig. 3.18. Arduino Esplora


The programming of this board can be done using Arduino Software like
IDE which takes the data from the inputs and controls the output like a
keyboard or a mouse. As compared with all other types of Arduino boards,
this esplora is totally different because the inputs, as well as outputs, are
connected to the board already.
So connecting the components like actuators or sensors is very simple.
Thus,programming is somewhat different as compared with other types ot
Arduino boards. This esplora board includes its own library so that e
datafrom the sensors & actuators are very easy to read and
wWTite.
3.5.4.13. Arduino Pro Mic
The Arduino Pro Micro board is the same as the Arduino Mini board apart
from the ATmega32U4 Microcontroller. This pro mic board includes
digital I/O pins-12, pulse width modulation (PWM)
pins->, s
connections of Tx &Rx &10-bit ADC.
IOT and. Arduino Programming |3.31|

3.5.4.14. Arduino Ethernet


The Arduino Ethernet board depends on the microcontroller like
ATmega328. This kind of microcontroller board includes analog pins-,
digital VO pins-14, RST button, an RJ45 connection, crystal oscillator, a
power jack, ICSP header, etc. The connection of the Arduino board can be
done through the Ethernet shield to the internet.
3.5.4.15. Arduino Zero

This is a powerful as well as simple 32-bit board and it provides the best
platform for innovative projects like wearable technology, smart IoT
devices, crazy robotics, high-tech automation, etc. This board expands by
providing improved performance, permitting a range of project
opportunities and performs like a great educational tool.

Fig. 3.19. Arduino Zero


This board includes analog input pins-6, digital I/O pins-14, a power jack,
AREF button, UART port pins, a USB connector & an In-Circuit Serial
Programming (ICSP) header, a power header, etc. This board is power
driven through the SAMD21 microcontroller based on Atmel. The main
feature of this is EDBG (Embedded Debugger) based on Atmel and it
provides a complete debug interface without using extra hardware.
3.5.4.16. Fastest ArduinoBoard
Designing one of the best Arduino development boards that are familiar with
Arduino MEGA & UNO is the hifivel board that includes a 320 MHz RISC-V
|3.32| Embedded
Systems and Ion
microcontroller unit. This kind of fastest board has Cortex M-7 with a400
microcontroller unit.
3 Flash memory - upto 2Mbytes
RAM-1 Mbyte
$ DMA controllers -4
$ Communication peripherals- Upto 35
16-bit Max Resolution with 3x ADCs
D/A converters with 2x 12-bit
Hardware with JPEG Codec
Timers -22&Watchdogs - 200Mhz
HW Calendar & RTC with Sub-second Accuracy
3 Cryptographic Acceleration
Hifive1 Board Features
The features of the Hifivel board include the following.
Mega Form Factor or Arduino Uno
Charger for Battery
SD Card including Detection of Card Feature
Ethernet*
$ Optional QSPI Flash - 133Mhz
Interfaces-CAN, SWD, Camera
USB- 0TG
3.5.4.17. The Arduino Shields
Additionally, Arduino shields are pre-built circuit boards used to connect t0
number of Arduino boards. These shields fit on the top of the Arduino compatibi
boards to provide additional capabilities like connecting to the internet, mou
controlling, providing wireless communication, LCD screen controlling, el.
different types of Arduino shields are
Wireless Shields
The GSM Shield
The Ethernet Shield
OTand,Arduino Programming |3.33|
The Proto Shields

Fig. 3.20. Shields for ArduinoBoards


265. ARDUINO BOARDS COMPARISON
The comparison between different Arduino boards includes the following.
Arduino
Voltage CLK Digital Analog
of Interface of
Board Speed I/O Inputs PWM UART
Programming
System
Arduino USB through
Uno - R3
5V 16MHz 14 14 6 1
ATMegal6U2
Arduino
Uno R3 5V 16MHz 14 14 6 1 USB through
SMD ATMegal6U2

RedBoard SV 16MHz 14 14 6 1 USB through


FTDI
Arduino FTDI
Pro 3.3V 8MHz 14 14 6 1
Compatible
3.3V/8MHz Header
Arduino FTDI
Pro 5V 16MHz 14 14 6 1
Compatible
SV/16MHz Header
FTDI
Arduino 16MHz 14 14 8 1
Compatible
Mini 05 SV
Header
|3.34| Embedded Systems andIOT

FTDI
Arduino
8MHz 14 14 6 1 Compatible
Pro Mini 3.3V
Header
3.3V/8MHz
FTDI
Arduino
16MHz 14 6 1 Compatible
Pro Mini 5V Header
SV/16MHz
FTDI
Arduino 16MHz 14 6 6 1 Compatible
Ethernet Header
FTDI
Compatible
Arduino 8 6 1 Header or
3.3V 8MHz 14
Fio Wirelessly via
XBeet

LilyPad FTDI
Arduino 6 6 1 Compatible
3.3V 8MHz 14
328 Main Header
Board
FTDI
LilyPad
Arduino 8MHZ 9 4 5 Compatible
3.3V Header
Simple
Board
RIGHT ARDUINO BOARD?
3.5.6. HOW TO SELECT THE
different types of Arduino boards existing in the market today
There are Arduino
best way to select the
such as the FreeDuino and NetDuino. The
names on the original
board is by checking and differentiating the trade
through online sites as
boards. So getting low-cost Arduino boards is easy
available with different versions
well as electronic stores. These boards are
as wellas specifications.
done with the Arduino DE
The programming of all the boards can be
but eat
software that pernmits anyone to write as well as upload the code,
board varies based on the inputs, outputs, speed, form factor, voltage, e
The voltage required to operate these boards range from 3.7V to 5V.
and Arduino Programming |3.35

3.6. ARDUINO TOOLCHAIN

At0ol chain is a set of programming tools that is used to perform a complex set of
operations. In the Arduino Software (|DE) the tool chain is hidden from the user, but
is used to compile and upload the user Sketch. It includes compiler, assembler,
linker and Standard C& math libraries.
Asoftware tool chain is a sct of software development tools used
simultaneously to complete complex software development tasks or to deliver a
cofware product. Each tool in the chain is itself a piece of software that serves a
isferent function and isoptimized to work together with other tools in the chain.
A
tool chain is simply a set of software tools that work together to complete a
task. for example, if we were going to hang a picture, the tool chain might include a
hammer, maybe a tape measure and some nails.

3.6.1. ARDUINO HARDWARE/SOFTWARE INTERFACE


When programming the Arduino it is possible to write some pretty complex
instructions and get the Arduino to do some really cool things. The problem isthat a
microcoritroller (like the ATmega328 on the Uno) can only execute simple, low-level
instructions. These simple instructions include things like add variable a to variable
bor Take care, variable b and put it in register x. And, to complicate matters,
microcontrollers only speak in binary.

Now Iget it!

10 1 010 1 0

Fig.3.21. Arduino and other microcontrollers only understand binary.


3.6.2. HOWTHE ARDUINOCOMPILER WORKS
* Compiling a program in Arduino is referred to as verifying. The compiler
first transforms the code you write into assembly language. The name of
the compiler we`ll be using on our Unois AVR-GCC.
The assembler, which come
language program into machine language. p
translates the assembly
Compiler Software Package th
Another
when we
Multiple Files ATMega32=
Assembler
loader was
to get the
and seamles

Linker
1
i
The figurebelow iS another way to view
3.22. Arduino code compilation process.
0
Fig.
.hex
C Program

Compiler

Assembly

Assembler

Object: Machine language Object: Library routine (machine code)

Linker 3.6.3. ARC


The IDE
Executable: Machine program
Arduinc
Loader
install on y
your device

Memory Althoug
Fig. 3.23. another way to visualize the Arduino code compilation proces developme
data,a When you
It then creates object files, which combine machine languag to install S.
Often,th
information it needs to place instructions properly in memory. finished, s
together.
assembler creates multiple files which will eventually be put
JOT md Arduino Programming |3.37|

The linker will take all the independently assembled machine language
programs andobject files and put them together. This produces a .hex file
that the microprocessor can understand and run.
Another piece of software, called AVR Dude (for Downloader UploaDEr) starts
.hex file to the
when we press the upload button. This software sends the
ATMega328 on the Arduino board. On the chip resides the boot loader. This boot
AVR Dude
loader was put there on purpose by the folks at Arduino and works with
to get the .hex into the flash memory on the chip. All of this happens very quickly
and seamlessly behind the scenes of the Arduino IDE.
AVR Dude
100
(Dude =
001
Downloader/UploaDEr)
.hex File

OOUNO
Hi, I'm the bootloader and |
live on the ATMega328 chip.

Fig. 3.24. how the compiled code transfers tothe Arduino board.

3.6.3. ARDUINO TOOL CHAIN EXAMPLE


The IDE
Arduino has an online editor to create sketches for your device. With an agent you
installon your computer, you can build your sketch and flash it over USB directly to
your device.:
Although the online editor is great, we will use the Arduino integrated
development environment or IDE. At the time of writing, the version was 1.8.2.
When you install and run it, and connect your MKRI000, you should get a message
When that is
to install SAMD support (the MKR1000 uses a SAMD21 Cortex-M0+).
Iinished, set your board to the MKR1000 from the Tools> Board menu.
3.38
Embedded Systems and
sketth_ mayl2b

EDITOR NEW SKETCt

Setctbcek $EARCH SRETCHBCDK stech rabino Aeackieadot

DR0EREY AST OFED

Thes it prints the atirss of the Wisi shidd,


` sketch_nmayl2b ihe P de'S btaied, id utrer tetuor% aetails.

Serotot

WiFi Firmware
You should make sure the WiFi firmware is up-to-date and is supported by the
WiFil01 library you will use. To check the WiFi firmware, navigate to Fle >
Examples > Wifil01 > Check WiFi101FimwareVersion. This will open the example
sketch that you now have to load on the device:
X
Checkwifi101FirmwareVersion Arduino 1.8.2
File Edit Sketch Toots Heip

CheckVifi 101Firrwareversion

4ir.:iude <sPI.h:
*inicde WiFil1.n
|3.39
10T and Arduino Programming

Use the button with the arrow pointing right (next to the button with the
abeckmark) to upload the firmware to the device. While uploading, press CTRI
SHIFT-M to open the Serial Monitor. You will see a message similar to the one
below:
6 COM3 (Arduino/Genuino MKR1000)

wiEil01 firmware check.

wiFil01 shield: DETECTED


Firmware version installed: 19.5.2
Latest firmware version availabla : 19.5.2

Check result: PASSED

Wifi101 Firmware/Certificates Updater X

1. Select port of the WiFi module


f the port is not listed click "Refresh list button to regenerate the list

COM3 Refresh list

Test connection

2. Update firmware
Select the firmware from the dropdown box below
WINC15ß1 Model 8(19.5.2)
Update Firmware

3. Update SSL root certificates

Add domains in the list below using "Add domain" button


arduino.CC:443 Add domain
wvw.azurewebsites.net:443
Renéve dman

Upload Certificates to WiFi module


3.40 Embedded Systems and lor
At the time of writing, firmware 19.5.2 was the latest firmware and
was
to be used with the WiFil01 library. If you do not pass the firmware reqired
check, the>
firmware should be updated. Open another example sketch under File >
Wifil01 called Firm ware Updater and upload it to the device. Examples
The Firm ware Updater firmware only prepares the device for updating
the
firmware. To actually perform the update, use Tools >WiFi101 Firmware UpdateWifi
Select the port (COM3 in my case) and click Test Connection. Wher
the
passes, select the latest firmware and click Update Firmware. As you can see hmtest
the screenshot, this tool also allows you to upload certificates.
3.7. ARDUINO PROGRAMMING STRUCTURE

The Arduino language is Ctt. The most important "high level" characteristic of
C++ is that it is object-oriented. In such a language, an object is a construct that
combines functional code (the code that does things like calculations and memory
operations), with "state" (the results of such calculations, or simply values, stored in
variables).
Object orientation made programming much more productive in most types of
applications when conmpared with earlier paradigms because it allowed programmers
touse abstractions to create complicated programs. For example, you could model an
Ethernet adaptor as an object that contains attributes (like its IP and MAC addresses)
and functionality (like asking a DHCP server for network configuration details).
Programming with objects became the most common paradigm in programning, and
most modern languages, like Java, Ruby, and Python, have been influenced heavily
by C++,
Much of the sketch code you will be writing and reading will be referencing
libraries containing definitions for objects (these definitions are called "classes")
Your original code, to a large extent, willconsist of "glue" code and customizations.
This way, you can be productive almost right away by learning a small subset of
C+t.
The code that makes up your sketch must be compiled into the machine code th§t
the microcontroller on the Arduino can understand. This compilation is done by &
special program, the compiler. The Arduino IDE ships with an open-source C+t, S0

You might also like