Lecture 04 05 IoT Systems Logical Design Using Arduino Part 1 2
Lecture 04 05 IoT Systems Logical Design Using Arduino Part 1 2
Chapter 4
IoT Systems - Logical Design
using Arduino (Part 1 & 2)
INTERNET OF THINGS A HANDS ON APPROACH
Objectives
▪ Better understanding of Arduino
▪ Mastery of Arduino hardware
▪ Programming for Arduino
▪ Simple sample projects
Topics
▪ What is Arduino?
▪ Hardware
▪ Programming the Arduino
▪ How to get started?
What is a Microcontroller?
A microcontroller (MCU for microcontroller
unit) is a small computer on a single metal-
oxide-semiconductor (MOS) integrated
circuit (IC) chip. A microcontroller contains
one or more CPUs (processor cores) along
with memory and programmable
input/output peripherals.
Arduino Microcontroller
▪ Open-source electronics platform
based on easy-to-use hardware and
software
▪ Interactive Installations
▪ Rapid Prototyping
Types of Arduinos
What is the difference between them?
Types of Arduino
Analog and digital pins
POWER
Hardware
BREADBOARDS
Hardware
JUMPER WIRES
Programming The Arduino
▪ Simplified C/C++
▪ Based on the wiring project: http://wiring.org.co
▪ Peripheral libraries: LCD, sensors, 12C, ect
Programming The Arduino
Useful functions
Programming The Arduino
Water
Tower
Water
Tower
V
V
Water Water
Tower Tower
Resistance
settings
Prototyping Circuits Solderless Breadboard
▪ One of the most useful tools in an engineer or Maker’s toolkit. The
three most important things:
• A breadboard is easier than soldering
• A lot of those little holes are connected, which ones?
• Sometimes breadboards break
What’s a Breadboard?
Solderless Breadboard
▪Vertical columns –
called power bus are
connected vertically
Using the Breadboard to built a simple circuit
▪What happens
when you break
the circuit?
▪What if you
wanted to add
more than one
LED?
Adding control – let’s use the Arduino and start programming!
Concepts: INPUT vs. OUTPUT
Referenced from the perspective of the microcontroller (electrical board).
Almost all systems that use physical computing will have some form of output
0V 0V
Open up Arduino
▪Hints:
▪For PC Users → For Mac Users →
1.Let the installer copy and move the 1. Move the Arduino
files to the appropriate locations, or executable to the dock
2.Create a folder under C:\Program Files for ease of access.
(x86) called Arduino. Move the entire 2. Resist the temptation to
Arduino program folder here. run these from your
desktop.
Integrated Development Environment (IDE)
Two required functions /
methods / routines:
void setup()
{
// runs once
}
void loop()
{
error & status messages // repeats
}
Settings: Tools → Serial Port
BIG 6 CONCEPTS
analogWrite()
digitalRead()
analogRead()
Serial communication
Let’s get to coding…
▪Project #1 – Blink
•“Hello World” of Physical Computing
▪ digitalWrite(pin, HIGH/LOW);
▪ ex: digitalWrite(13, HIGH);
▪ delay(time_ms);
▪ ex: delay(2500); // delay of 2.5 sec.
▪ Challenge 1c – find the fastest blink that the human eye can
still detect…
▪ 1 ms delay? 2 ms delay? 3 ms delay???
▪
Try adding other LEDs
Programming Concepts: Variables
Variable Scope
▪Global
▪---
▪Function-level
Programming Concepts: Variable Types
▪ Variable Types:
▪analogWrite(pin, val);
Color Mixing
Tri-color LED