Analog Input

Download Report

Transcript Analog Input

Introduction
1
Microcontrollers
• Programmers work in the virtual world.
• Machinery works in the physical world.
• The microcontroller connects the virtual world
to the physical world
• A microcontroller is a small-scale computer
with generalized (and programmable) inputs
and outputs.
• The inputs and outputs can be manipulated
by, and can manipulate, the physical world.
2
3
Arduino is software
• Including an Integrated
Development Environment
(IDE) for programming.
• It’s used to edit code as if
editing a word document
• The platform is used to
create the “process”, compile
it, and then upload it to the
microcontroller.
• The language itself is based
in C and is called ‘wiring’
4
Arduino is a platform
•
A physical Input / Output
board (I/O) with a
programmable
Integrated Circuit (IC).
5
Why Arduino?
• It is Open Source, both in terms of Hardware and
Software. Anyone who wants can copy it for free
• It is cheap, the hardware can be built from components
or a prefab board can be purchased for as little as $15
• It can communicate with a computer via serial
connection over USB (common interfaces)
• It can be powered from USB or standalone DC power.
• It can run standalone from a computer (chip is
programmable) and it has memory (a small amount).
6
What can it do?
• Sensors ( to sense stuff )
–
–
–
–
–
Push buttons, touch pads, tilt switches.
Variable resistors (eg. volume knob / sliders)
Photoresistors (sensing light levels)
Thermistors (temperature)
Ultrasound (proximity range finder)
• Actuators ( to do stuff )
–
–
–
–
[ INPUTS ]
Lights, LED’s
Motors
Speakers
Displays (LCD)
[ OUTPUTS ]
CURRENT LIMITS!!!
7
Autonomous
Vehicle
8
Laser Harp
9
Clock
10
Sign Language Glove
11
Interfacing
12
Interfacing
• Plugs into pins like a
breadboard
13
14
15
16
Inputs and Outputs
17
Concepts: INPUT vs. OUTPUT
•Referenced from the perspective of the
microcontroller (electrical board).
Inputs is a signal / information going
Output is any signal exiting the
into the board.
board.
18
Concepts: INPUT vs. OUTPUT
•Referenced from the perspective of the
microcontroller (electrical board).
Inputs is a signal / information going
Output is any signal exiting the
into the board.
board.
Examples:
Buttons Switches, Light
Sensors, Flex Sensors,
Humidity Sensors,
Temperature Sensors…
Examples:
LEDs, DC motor,
servo motor,
piezo buzzer,
relay, RGB LED
19
Analog vs. Digital
20
Analog vs. Digital
• Computers “naturally” talk in a digital language. Things
are either “ON” or “OFF”, “HIGH” or “LOW”, “1” or “0”,
“5V or 0V”
• Our physical world is analog. Things can be “medium”,
“warm”, “37 mph”, “92 degrees”
• So how do we create 2.75 volts if all we have is 0 and 5?
• With a technique called Pulse width Modulation (PWM)
• Imagine turning a fan off and on every second. It would
operate at a “medium” speed.
• The longer the pulses (ON’s), the higher the average
voltage and the actual voltage output.
21
Analog vs. Digital
22
Analog vs. Digital
Fixed cycle length:
constant number of cycles/sec
23
BIG 4 CONCEPTS
digitalWrite()
analogWrite()
digitalRead()
analogRead()
24
Components
Type
Function
Push Button
Digital Input
Switch - Closes or
opens circuit
Potentiometer
Analog Input
Variable resistor
Photoresistor
Analog Input
Light Dependent
Resistor (LDR)
Relay
Digital Output
Switch driven by a
small signal
Temp Sensor
Analog Input
Temp Dependent
Resistor
Flex Sensor
Analog Input
Variable resistor
Soft Trimpot
Analog Input
Variable resistor
RGB LED
Dig & Analog
Output
16,777,216 different
colors
Name
Image
25
Scales
26
Scales
Physical
0V
5V
Digital Write
LOW (0)
HIGH (1)
Digital Read
LOW (0)
HIGH (1)
Analog Read
0
1023
Analog Write
0
255
27