Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
97 views

Intro To Arduino

The document introduces the Arduino board. It was created in 2005 in Italy as an open source hardware platform. The Arduino board allows users to code in languages like C++ and Processing and features inputs and outputs that can be used to build interactive projects. The board connects to a computer via USB and features a microcontroller, power connections, digital and analog pins that can be used as inputs or outputs, and a reset button. Breadboards allow users to easily prototype circuits by connecting components without soldering. The Arduino IDE is used to write code that can control outputs and respond to inputs using functions like digitalWrite, analogWrite, and delay.

Uploaded by

Gkid Gkid
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

Intro To Arduino

The document introduces the Arduino board. It was created in 2005 in Italy as an open source hardware platform. The Arduino board allows users to code in languages like C++ and Processing and features inputs and outputs that can be used to build interactive projects. The board connects to a computer via USB and features a microcontroller, power connections, digital and analog pins that can be used as inputs or outputs, and a reset button. Breadboards allow users to easily prototype circuits by connecting components without soldering. The Arduino IDE is used to write code that can control outputs and respond to inputs using functions like digitalWrite, analogWrite, and delay.

Uploaded by

Gkid Gkid
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 39

Introduction

of Arduino
Arduino Board
• Created in Ivrea, Italy in 2005 by Massimo Banzi & David Cuartielles
• Open Source Hardware
• Coding is accessible & transferrable  (C++, Processing, java)
Arduino…

http://spectrum.ieee.org/geek-life/hands-on/the-making-of-arduino
PWR IN USB
(to Computer)

RESET

SCL\SDA
(I2C Bus)

POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)

Analog
INPUTS
Go ahead and plug your board in!
SIK Components
Name Image Type Function Notes
Push Button Digital Input Switch - Closes Polarized, needs
or opens circuit resistor
Trim Analog Input Variable resistor Also called a
Trimpot.
potentiometer
Photoresistor Analog Input Light Dependent Resistance varies
Resistor (LDR) with light.
Relay Digital Output Switch driven by Used to control
a small signal larger voltages
Temp Sensor Analog Input Temp Dependent
Resistor
Flex Sensor Analog Input Variable resistor

Soft Trimpot Analog Input Variable resistor Careful of shorts

RGB LED Dig & Analog 16,777,216 Ooh... So pretty.


Output different colors
SIK Components
SIK Components
What’s a Breadboard?
Solderless Breadboard

Each row (horiz.) of 5


holes are connected.

Vertical columns –
called power bus are
connected vertically
Using the Breadboard to built a simple
circuit

Use the breadboard to


wire up a single LED
with a 330 Ohm
Resistor (Orange-
Orange-Brown).

Note: the longer leg on the


LED is the positive leg and
the shorter leg is the
negative
Fritzing View of Breadboard 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
Microcontroller (electrical board).
Inputs is a signal / Output is any signal
information going into exiting the board.
the board.

Almost all systems that use physical computing will


have some form of output

What are some examples of Outputs?


Concepts: INPUT vs. OUTPUT
Inputs is a signal / Output is any signal
information going into exiting the board.
the board.

Examples: Buttons Examples: LEDs, DC motor,


Switches, Light Sensors, servo motor, a piezo buzzer,
Flex Sensors, Humidity relay, an RGB LED
Sensors, Temperature
Sensors…
Concepts: Analog vs. Digital
Microcontrollers are digital devices – ON or OFF. Also
called – discrete.

analog signals are anything that can be a full range of


values. What are some examples? More on this later…

5V 5V

0V 0V
Open up Arduino

Hints:
For PC Users 
1.Create a folder under C:\Program Files (x86)
called Arduino. Move the entire Arduino
program folder here.
Arduino
Integrated Development Environment (IDE)

Two required functions /


methods / routines:

void setup()
{
// runs once
}

void loop()
{
// repeats
error & status messages }
Settings: Tools  Serial Port

Your computer
communicates to the
Arduino microcontroller via
a serial port  through a
USB-Serial adapter.

Check to make sure that the


drivers are properly
installed.
Settings: Tools  Board

Next, double-check that the proper board is


selected under the ToolsBoard menu.
Arduino & Arduino Compatible Boards
digitalWrite()
BIG 6 CONCEPTS
analogWrite()

digitalRead()

if() statements / Boolean

analogRead()

Serial communication
Let’s get to coding…

Project #1 – Blink
“Hello World” of Physical Computing

Psuedo-code – how should this work?

Turn
Turn Rinse &
Wait LED Wait
LED ON Repeat
OFF
Comments, Comments, Comments
Comments are for you – the programmer and
your friends…or anyone else human that
might read your code.

// this is for single line comments


// it’s good to put a description at the top and
before anything ‘tricky’
/* this is for multi-line comments
Like this…
And this….
comments
Three commands to know…

pinMode(pin, INPUT/OUTPUT);
ex: pinMode(13, OUTPUT);

digitalWrite(pin, HIGH/LOW);
ex: digitalWrite(13, HIGH);

delay(time_ms);
ex: delay(2500); // delay of 2.5 sec.

// NOTE: -> commands are CASE-sensitive


Project #1: Wiring Diagram

Move the
green wire
from the
power bus to
pin 13 (or any
other Digital
I/O pin on the
Arduino board.
A few simple challenges
Let’s make LED#13 blink!
Challenge 1a – blink with a 200 ms second
interval.

Challenge 1b – blink to mimic a heartbeat

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

Can you blink two, three, or four


LEDs?
(note: Each LED will need 330 W
resistor.)

How about Police Light?


Programming Concepts: Variables

Variable Scope

Global
---
Function-level
Programming Concepts: Variable Types
Variable Types:

8 bits 16 bits 32 bits

byte int long


char unsigned int unsigned long
float
Fading in and Fading Out
(Analog or Digital?)
A few pins on the Arduino allow for us to
modify the output to mimic an analog signal.

This is done by a technique called:


Pulse Width Modulation (PWM)
Concepts: Analog vs. Digital
To create an analog signal, the microcontroller uses a
technique called PWM. By varying the duty cycle, we
can mimic an “average” analog voltage.

Pulse Width Modulation (PWM)


Project #2 – Fading
Introducing a new command…

analogWrite(pin, val);

pin – refers to the OUTPUT pin


(limited to pins 3, 5, 6, 9, 10, 11.) –
denoted by a ~ symbol

val – 8 bit value (0 – 255).


0 => 0V | 255 => 5V
Move one of your LED pins over to Pin 9

In Arduino, open up:


File  Examples  01.Basics  Fade
Fade - Code Review
Fade - Code Review
End of First Part
PWR IN USB
(to Computer)

RESET

SCL\SDA
(I2C Bus)

POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)

Analog
INPUTS

You might also like