CMPE 30184
MICROPROCESSORS and MICROCONTROLLERS
What is Physical Computing?
MICROPROCESSORS and MICROCONTROLLERS
What is Arduino?
Arduino Boards
Arduino Shields
Arduino Uno Hardware
Arduino IDE
MICROPROCESSORS and MICROCONTROLLERS
MICROPROCESSORS and MICROCONTROLLERS
MICROPROCESSORS and MICROCONTROLLERS
“Arduino is an open-source physical
computing platform based on a simple I/O
board and a development environment that
implements the Processing / Wiring
language. Arduino can be used to develop
stand-alone interactive objects or can be
connected to software on your computer.“
( www.arduino.cc, 2006 )
MICROPROCESSORS and MICROCONTROLLERS
MICROPROCESSORS and MICROCONTROLLERS
Open Source Physical Computing Platform
− “open source hardware”
− open source: free to inspect & modify
− physical computing
ubiquitous computing
pervasive computing
ambient intelligence
calm computing
Spimes
Blogjects
smart objects
Community-built
− Examples wiki (the “playground”) editable by anyone
− Forums with lots of helpful people
MICROPROCESSORS and MICROCONTROLLERS
MICROPROCESSORS and MICROCONTROLLERS
Who are the Arduino founders?
The founders of Arduino are Massimo Banzi, David
Cuartielles, Tom Igoe, Gianluca Martino, David
Mellis, and Nicholas Zambetti. The Arduino project
was started in 2005 as a collaborative effort between
these individuals at the Interaction Design Institute
Ivrea in Italy. The goal of the project was to create an
easy-to-use platform for prototyping and DIY
electronics projects using microcontrollers. Since its
inception, the Arduino platform has grown in
popularity and has become a key tool for makers,
students, and hobbyists around the world.
Arduino is a single-board open-source platform
MICROPROCESSORS and MICROCONTROLLERS
for building electronic projects
Arduino consists of two components:
MICROPROCESSORS and MICROCONTROLLERS
−(1) a physical programmable circuit board designed
around an Atmel microcontroller, and
−(2) an Integrated Development Environment (IDE)
which is used to write the code on a computer, and
then upload it to the physical board.
Arduino does not need a separate piece of
MICROPROCESSORS and MICROCONTROLLERS
hardware (called a programmer) to load new
code onto the board – you can simply use a USB
cable.
Arduino IDE uses a
MICROPROCESSORS and MICROCONTROLLERS
simplified version of
C++, making it easier
to learn to program.
Arduino provides many
MICROPROCESSORS and MICROCONTROLLERS
alternative boards.
These boards vary in the
following aspects:
−the microcontroller type,
−The microcontroller speed
(frequency)
−the physical size,
−the number of input and output pins,
−the memory space for programs, and
−the board price.
Examples of Ardunio boards include:
MICROPROCESSORS and MICROCONTROLLERS
Arduino Uno Arduino Leonardo Arduino Due
Arduino Micro Arduino Mega 2560 Arduino Nano
a quick comparison between the characteristics of some Arduino boards
We can add functionality to an Arduino board by
MICROPROCESSORS and MICROCONTROLLERS
attaching shields.
A shield is a circuit board that connects via pins to
the sockets on the sides of an Arduino.
Hundreds of shields are available on the market.
Examples of these shields include:
−GSM Shield
−Ethernet Shield
−WiFi Shield
The GSM Shield with a SIM card allows an Arduino
MICROPROCESSORS and MICROCONTROLLERS
board to connect to the internet, make/receive
voice calls and send/receive SMS messages.
The Ethernet Shield allows an Arduino board to
MICROPROCESSORS and MICROCONTROLLERS
connect to the internet. It provides a network (IP)
stack capable of both TCP and UDP.
The WiFi Shield allows an Arduino board to
MICROPROCESSORS and MICROCONTROLLERS
connect to the internet using the 802.11 wireless
specification (WiFi). It provides a network (IP)
stack capable of both TCP and UDP.
MICROPROCESSORS and MICROCONTROLLERS
The Arduino Uno is a microcontroller board based
MICROPROCESSORS and MICROCONTROLLERS
on the ATmega328.
It has the following main parts:
−an ATmega382 microcontroller,
−a 16MHz clock,
−14 digital input/output pins (of which 6 can be used as
PWM outputs),
−6 analog inputs,
−an ICSP header,
−a USB connection,
−a power jack
−a reset button, and
−on board LEDs
The Universal Serial Bus (USB)
MICROPROCESSORS and MICROCONTROLLERS
connector connects the board to a
computer for three reasons:
−(1) to supply power to the
board
−(2) to upload code to the
Arduino
−(3) to send data to and receive
it from a computer.
The Power Connector is used to
power the Arduino with a
standard mains power adapter.
The microcontroller is a special type of processors
MICROPROCESSORS and MICROCONTROLLERS
that …
−includes various types of memory to hold data and
programs,
−executes instructions, and
−provides various means of sending and receiving data.
This row of pins offers power connections and the ability to use an
MICROPROCESSORS and MICROCONTROLLERS
external RESET button.
The power pins are as follows:
− VIN: This pin is used to receive input voltage to the Arduino board
when it's using an external power source.
− 5V:This pin outputs a regulated 5V from the regulator on the board.
− 3.3V: This pin outputs a regulated 3.3V from the regulator on the
board.
− GND. This pin provides the Ground signal.
− IOREF: This pin on the Arduino board provides the voltage reference
with which the microcontroller operates.
This row of pins offers six analog inputs that are
MICROPROCESSORS and MICROCONTROLLERS
used to measure electrical signals that vary in
voltage.
Furthermore, pins A4 and A5 can also be used for
sending data to and receiving it from other devices.
Pins numbered 0 to 13 are digital input/output (I/O)
MICROPROCESSORS and MICROCONTROLLERS
pins.
Pins 0 (RX) and 1 (TX) are also known as the serial
port, which is used to send and receive serial data to
other devices.
The pins labeled with a tilde (~) can also generate a
varying electrical signal (PWM).
The Arduino IDE
MICROPROCESSORS and MICROCONTROLLERS
IDE stands for Integrated
Development Environment
Arduino's IDE is
completely based on the
Processing IDE since
September 2005
Using the IDE is a 3-step
process:
1) Write your code
2) Compile the code
28 3) Upload to Arduino
FILE MENU
NEW, SAVE, OPEN,
EXAMPLES…
MICROPROCESSORS and MICROCONTROLLERS
EDIT MENU
CUT, PASTE, FIND…
TOOLS MENU
COM-PORT SETTINGS,
TOOLS,
BOARD TYPE
29
VERIFY / COMPILE
MICROPROCESSORS and MICROCONTROLLERS
NEW SKETCH
OPEN SKETCH
SAVE SKETCH
UPLOAD
SERIAL MONITOR
30
Code structure
MICROPROCESSORS and MICROCONTROLLERS
Variable declaration
Variables are containers for values.
You can give a variable any name you
like.
The value of a variable can be
changed and used dynamically as
many times as you like.
Variables are good to use when you
use values more than once in your
program.
Arduino Uno has 32 kilobytes of flash
memory and can store up to 1024
bytes as variables.
31
Code structure
MICROPROCESSORS and MICROCONTROLLERS
The setup method
The Setup method is used to initiate
the board before the code gets
executed.
This code runs only once when the
reset button has been pressed.
It defines if pins should be used as
inputs or outputs, whether serial
communication is going to be used,
etc.
32
Code structure
MICROPROCESSORS and MICROCONTROLLERS
The program loop
The loop is where the action is!
This is where you write your program
It executes from top to bottom, line by
line, and then starts over (looping back).
33