0% found this document useful (0 votes)
23 views

Arduino Part II

Uploaded by

Yordanos Tefera
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Arduino Part II

Uploaded by

Yordanos Tefera
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Chapter 4:

ARDUINO
Part II

BY: Gemmachis Teshite


College of Computing and Informatics
Haramaya University
CONTENTS
 What is ARDUINO ?
 ARDUINO Software (IDE)
 Uploading
 Libraries
 Boards
 Installing Additional Arduino
 Installing Additional Cores
What is ARDUINO ?
 Arduino is an open-source prototyping platform based on easy-to-
use hardware and software.
 Arduino boards are able to read inputs - light on a sensor, a finger
on a button, or a Twitter message - and turn it into an output -
activating a motor, turning on an LED, publishing something
online.
 You can tell your board what to do by sending a set of instructions
to the microcontroller on the board.
 To do so you use the Arduino programming language (based on
Wiring), and the Arduino Software (IDE), based on Processing.
 Over the years Arduino has been the brain of thousands of projects,
from everyday objects to complex scientific instruments.
 A worldwide community of makers - students, hobbyists, artists,
programmers, and professionals - has gathered around this open-
source platform, their contributions have added up to an incredible
amount of accessible knowledge that can be of great help to novices
Cont’d…
 Arduino was born at the Ivrea Interaction Design Institute as an
easy tool for fast prototyping, aimed at students without a background in
electronics and programming.
 As soon as it reached a wider community, the Arduino board started
changing to adapt to new needs and challenges, differentiating its offer
from simple 8-bit boards to products for IoT applications, wearable,
3D printing, and embedded environments.
 All Arduino boards are completely open-source, empowering users to
build them independently and eventually adapt them to their particular
needs.
 The software, too, is open-source, and it is growing through the
contributions of users worldwide.
 The Arduino software is easy-to-use for beginners, yet flexible enough
for advanced users.
 It runs on Mac, Windows, and Linux.
Cont’d…
 There are many other microcontrollers and microcontroller
platforms available for physical computing.
 Parallax Basic Stamp,
 Netmedia's BX-24,
 Phidgets,
 MIT's Handyboard, and many others offer similar
functionality.
 All of these tools take the messy details of microcontroller
programming and wrap it up in an easy-to-use package.
Cont’d…
 Arduino also simplifies the process of working with microcontrollers, but
it offers some advantage for teachers, students, and interested
amateurs over other systems:
 Inexpensive - Arduino boards are relatively inexpensive compared
to other microcontroller platforms. The least expensive version of the
Arduino module can be assembled by hand, and even the pre-
assembled Arduino modules cost less than $50
 Cross-platform - The Arduino Software (IDE) runs on Windows,
Macintosh OSX, and Linux operating systems. Most microcontroller
systems are limited to Windows.
 Simple, clear programming environment - The Arduino Software
(IDE) is easy-to-use for beginners, yet flexible enough for advanced
users to take advantage of as well. For teachers, it's conveniently
based on the Processing programming environment, so students
learning to program in that environment will be familiar with how the
Arduino IDE works.
Cont’d…
 Open source and extensible software - The Arduino
software is published as open source tools, available for
extension by experienced programmers. The language can be
expanded through C++ libraries, and people wanting to
understand the technical details can make the leap from
Arduino to the AVR C programming language on which it's
based. Similarly, you can add AVR-C code directly into your
Arduino programs if you want to.
 Open source and extensible hardware - The plans of the
Arduino boards are published under a Creative Commons
license, so experienced circuit designers can make their own
version of the module, extending it and improving it. Even
relatively inexperienced users can build the breadboard
version of the module in order to understand how it works and
save money.
ARDUINO SOFTWARE (IDE)
 The Arduino Integrated Development Environment - or Arduino
Software (IDE) - contains a text editor for writing code, a
message area, a text console, a toolbar with buttons for
common functions and a series of menus.
 It connects to the Arduino and Genuino hardware to upload
programs and communicate with them.
 The Arduino IDE uses a simplified version of C++, making it
easier to learn to program.
Writing Sketches
 Programs written using Arduino Software (IDE) are called sketches.
 These sketches are written in the text editor and are saved with the
file extension .ino.
 The editor has features for cutting/pasting and for
searching/replacing text.
 The message area gives feedback while saving and exporting and
also displays errors.
 The console displays text output by the Arduino Software (IDE),
including complete error messages and other information.
 The bottom right-hand corner of the window displays the
configured board and serial port.
 The toolbar buttons allow you to verify and upload programs,
create, open, and save sketches, and open the serial monitor.
Cont’d…
Verify
Checks your code for errors compiling it.
Upload
Compiles your code and uploads it to the configured board.
Note: If you are using an external programmer with your board, you can hold down the "shift" key
on your computer when using this icon. The text will change to "Upload using Programmer"
New
Creates a new sketch.
Open
Presents a menu of all the sketches in your sketchbook. Clicking one will open it within the current
window overwriting its content.
Save
Saves your sketch.
Serial Monitor
Opens the serial monitor.
Save
Saves your sketch.
Sketchbook
 The Arduino Software (IDE) uses the concept of a sketchbook: a
standard place to store your programs (or sketches).
 The sketches in your sketchbook can be opened from the File >
Sketchbook menu or from the Open button on the toolbar.
 The first time you run the Arduino software, it will automatically
create a
directory for your sketchbook.
 You can view or change the location of the sketchbook location from
with the Preferences dialog.

Tabs, Multiple Files, and Compilation


 Allows you to manage sketches with more than one file (each of
which appears in its own tab).
 These can be normal Arduino code files (no visible extension), C
files (.c extension), C++ files (.cpp), or header files (.h).
Uploading
 Before uploading your sketch, you need to select the correct items from the
Tools > Board and Tools > Port menus.
 On the Mac, the serial port is probably something like
/dev/tty.usbmodem241 (for an Uno or Mega2560 or Leonardo) or
/dev/tty.usbserial-1B1 (for a
Duemilanove or earlier USB board), or /dev/tty.USA19QW1b1P1.1 (for
a serial board connected with a Keyspan USB-to-Serial adapter).
 On Windows, it's probably COM1 or COM2 (for a serial board) or
COM4, COM5, COM7, or higher (for a USB board) - to find out, you
look for USB serial device in the ports section of the Windows Device
Manager.
 On Linux, it should be /dev/ttyACMx , /dev/ttyUSBx or similar.

 Once you've selected the correct serial port and board, press the
upload button in the toolbar or select the Upload item from the File
menu.
 Current Arduino boards will reset automatically and begin the upload.
Cont’d…
 The Arduino Software (IDE) will display a message when the
upload is complete, or show an error.
 When you upload a sketch, you're using the Arduino
bootloader, a small program that has been loaded on to the
microcontroller on your board.
 It allows you to upload code without using any additional
hardware.
 The bootloader is active for a few seconds when the board
resets; then it starts whichever sketch was most recently
uploaded to the microcontroller. The bootloader will blink the
on-board (pin 13) LED when it starts (i.e. when the board
resets)
Libraries
 Libraries provide extra functionality for use in sketches, e.g. working with
hardware or manipulating data.
 To use a library in a sketch, select it from the Sketch > Import Library
menu. This will insert one or more #include statements at the top of the
sketch and compile the library with your sketch.
 Because libraries are uploaded to the board with your sketch, they increase
the amount of space it takes up.
 If a sketch no longer needs a library, simply delete its #include
statements from the top of your code.
 There is a list of libraries in the reference. Some libraries are included with
the Arduino software.
 Others can be downloaded from a variety of sources or through the
Library Manager. Starting with version 1.0.5 of the IDE, you do can
import a library from a zip file and use it in an open sketch. See these
instructions for installing a third-party library.
Third-Party Hardware
 Support for third-party hardware can be added to the hardware directory of
your sketchbook directory.
 Platforms installed there may include board definitions (which appear in the
board menu), core libraries, bootloaders, and programmer definitions.
 To install, create the hardware directory, then unzip the third-party platform
into its own sub-directory. (Don't use "arduino" as the sub-directory name or
you'll override the built-in Arduino platform.) To uninstall, simply delete its
directory.
Serial Monitor
 Displays serial data being sent from the Arduino or Genuino board (USB or
serial board).
 To send data to the board, enter text and click on the "send" button or press
enter.
 Choose the baud rate from the drop-down that matches the rate passed to
Serial.begin in your sketch.
 Note that on Windows, Mac or Linux, the Arduino or Genuino board will reset
(rerun your sketch execution to the beginning) when you connect with the
Preferences
 Some preferences can be set in the preferences dialog (found
under the Arduino menu on the Mac, or File on Windows and
Linux).
 The rest can be found in the preferences file, whose location is
shown in the preference dialog.
Boards
 The board selection has two effects: it sets the parameters
(e.g. CPU speed and baud rate) used when compiling and
uploading sketches; and sets and the file and fuse settings
used by the burn bootloader command.
 Some of the board definitions differ only in the latter, so even
if you've been uploading successfully with a particular
selection you'll want to check it before burning the bootloader.
 Arduino Software (IDE) includes the built in support for the
boards in the following list, all based on the AVR Core.
 The Boards Manager included in the standard installation
allows to add support for the growing number of new boards
based on different cores like Arduino Due, Arduino Zero,
Edison, Galileo and so on.
Cont’d…
Arduino Yùn
 An ATmega32u4 running at 16 MHz with auto-reset, 12 Analog In, 20 Digital
I/O and 7 PWM.
Arduino/Genuino Uno
 An ATmega328 running at 16 MHz with auto-reset, 6 Analog In, 14 Digital I/O
and 6 PWM.
Arduino Diecimila or Duemilanove w/ ATmega168
 An ATmega168 running at 16 MHz with auto-reset.
Arduino Nano w/ ATmega328
 An ATmega328 running at 16 MHz with auto-reset. Has eight analog inputs.
Arduino/Genuino Mega 2560
 An ATmega2560 running at 16 MHz with auto-reset, 16 Analog In, 54 Digital
I/O and 15 PWM.
Arduino Mega
 An ATmega1280 running at 16 MHz with auto-reset, 16 Analog In, 54 Digital I/O and
15 PWM.
Cont’d…
Arduino Mega ADK
 An ATmega2560 running at 16 MHz with auto-reset, 16 Analog In, 54 Digital I/O
and 15 PWM.
Arduino Leonardo
 An ATmega32u4 running at 16 MHz with auto-reset, 12 Analog In, 20 Digital I/O
and 7 PWM.
Arduino Micro
 An ATmega32u4 running at 16 MHz with auto-reset, 12 Analog In, 20 Digital I/O and 7
PWM.
Arduino Esplora
 An ATmega32u4 running at 16 MHz with auto-reset.
Arduino Mini w/ ATmega328
 An ATmega328 running at 16 MHz with auto-reset, 8 Analog In, 14 Digital I/O
and 6 PWM.
Arduino Ethernet
 Equivalent to Arduino UNO with an Ethernet shield: An ATmega328 running at
16 MHz with autoreset, 6 Analog In, 14 Digital I/O and 6 PWM.
Cont’d…
Arduino Fio
 An ATmega328 running at 8 MHz with auto-reset. Equivalent to Arduino Pro or Pro Mini
(3.3V, 8 MHz) w/ ATmega328, 6 Analog In, 14 Digital I/O and 6 PWM.
Arduino BT w/ ATmega328
 ATmega328 running at 16 MHz. The bootloader burned (4 KB) includes codes to
initialize the onboard bluetooth module, 6 Analog In, 14 Digital I/O and 6 PWM..
LilyPad Arduino USB
 An ATmega32u4 running at 8 MHz with auto-reset, 4 Analog In, 9 Digital I/O and
4 PWM.
LilyPad Arduino
 An ATmega168 or ATmega132 running at 8 MHz with auto-reset, 6 Analog In, 14 Digital I/O
and 6 PWM.
Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
 An ATmega328 running at 16 MHz with auto-reset. Equivalent to Arduino
Duemilanove or Nano w/ ATmega328; 6 Analog In, 14 Digital I/O and 6 PWM.
Cont’d…
Arduino NG or older w/ ATmega168
 An ATmega168 running at 16 MHz without auto-reset. Compilation and
upload is equivalent to Arduino Diecimila or Duemilanove w/
ATmega168, but the bootloader burned has a slower timeout (and
blinks the pin 13 LED three times on reset); 6 Analog In, 14 Digital I/O
and 6 PWM.
Arduino Robot Control
 An ATmega328 running at 16 MHz with auto-reset.
Arduino Robot Motor
 An ATmega328 running at 16 MHz with auto-reset.
Arduino Gemma
 An ATtiny85 running at 8 MHz with auto-reset, 1 Analog In, 3 Digital I/O
and 2 PWM.
Installing Additional Arduino
 Once you are comfortable with the Arduino software and using
the built-in functions, you may want to extend the ability of
your Arduino with additional libraries.
What are Libraries?
 Libraries are a collection of code that makes it easy for you to
connect to a sensor, display, module, etc. For example, the
built-in LiquidCrystal library makes it easy to talk to
character LCD displays.
 There are hundreds of additional libraries available on the
Internet for download. The built-in libraries and some of these
additional libraries are listed in the reference.
 To use the additional libraries, you will need to install them.
How to Install a Library
 Using the Library Manager
To install a new library into your Arduino IDE you can use the Library
Manager (available from IDE version 1.6.2). Open the IDE and click to the
"Sketch" menu and then Include Library > Manage Libraries.
Cont’d…
 Then the library manager will open and you will find a list of libraries that are
already installed or ready for installation.
 In this example we will install the Bridge library. Scroll the list to find it, then select
the version of the library you want to install. Sometimes only one version of the
library is available. If the version selection menu does not appear, don't worry: it is
normal.

 Finally click on install and wait for the IDE to install the new library. Downloading
may take time depending on your connection speed. Once it has finished, an
Cont’d…

 You can now find the new library available in the Include Library menu. If
you want to add your own library open a new issue on github.
Importing a .zip Library
 Libraries are often distributed as a ZIP file or folder. The name of the folder is the
name of the library.
 Inside the folder will be a .cpp file, a .h file and often a keywords.txt file,
examples folder, and other files required by the library.
 Starting with version 1.0.5, you can install 3rd party libraries in the IDE. Do not
unzip the downloaded library, leave it as is.
 In the Arduino IDE, navigate to Sketch > Include Library. At the top of the drop
down list, select the option to "Add .ZIP Library''.
Cont’d…
 You will be prompted to select the library you would like to add. Navigate to the .zip
file's location and open it.
Cont’d…
 Return to the Sketch > Import Library menu. You should now see the library at
the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file
will have been expanded in the libraries folder in your Arduino sketches directory.
NB: the Library will be available to use in sketches, but examples for the library will
not be exposed in the
 File > Examples until after the IDE has restarted.

Manual installation
 To install the library, first quit the Arduino application. Then uncompress the ZIP file
containing the library.
For example, if you're installing a library called "ArduinoParty", uncompress
ArduinoParty.zip. It should
contain a folder called ArduinoParty, with files like ArduinoParty.cpp and
ArduinoParty.h inside. (If the
.cpp and .h files aren't in a folder, you'll need to create one. In this case, you'd
make a folder called "ArduinoParty" and move into it all the files that were in the
ZIP file, like ArduinoParty.cpp and ArduinoParty.h.)
Cont’d…
 Drag the ArduinoParty folder into this folder (your libraries folder). Under Windows, it will
likely be called
"My Documents\Arduino\libraries". For Mac users, it will likely be called
"Documents/Arduino/libraries".
On Linux, it will be the "libraries" folder in your sketchbook.
Your Arduino library folder should now look like this (on Windows):
My Documents\Arduino\libraries\ArduinoParty\ArduinoParty.cpp
My Documents\Arduino\libraries\ArduinoParty\ArduinoParty.h
My Documents\Arduino\libraries\ArduinoParty\examples
....
or like this (on Mac and Linux):
Documents/Arduino/libraries/ArduinoParty/ArduinoParty.cpp
Documents/Arduino/libraries/ArduinoParty/ArduinoParty.h
Documents/Arduino/libraries/ArduinoParty/examples
....
There may be more files than just the .cpp and .h files, just make sure they're all there. (The
library won't work if you put the .cpp and .h files directly into the libraries folder or if they're
nested in an extra folder.
For example: Documents\Arduino\libraries\ArduinoParty.cpp and
Documents\Arduino\libraries\ArduinoParty\ArduinoParty\ArduinoParty.cpp won't work.)

 Restart the Arduino application. Make sure the new library appears in the Sketch->Import
Library menu item of the software. That's it! You've installed a library!
Installing additional Arduino Cores
 Starting from the IDE version 1.6.2, only AVR Arduino boards are installed by
default.
 Some Arduino boards require an additional Core to be installed
 One example is the Arduino Due, which uses an ARM/SAM microcontroller. In
order for the Arduino IDE to be able to program an Arduino Due, you need to install
the SAM Core using the Boards Manager
How to install a core
 In this example we will install the core required by the Arduino Due board.
Click on Tools menu and then Boards > Boards Manager
Cont’d…
 The board manager will open and you will see a list of installed
and available boards.
 Select the SAM core, choose the version in the drop-down
menu and click on install.
Cont’d…
 The download time will depend on your connection speed.

 After installation is complete an Installed tag appears next to the core


name.
 You can close the Board Manager.
 Now you can find the new board in the Board menu.

You might also like