Download Analog Input and Output

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Switched-mode power supply wikipedia , lookup

Pulse-width modulation wikipedia , lookup

Analog-to-digital converter wikipedia , lookup

Rectiverter wikipedia , lookup

Opto-isolator wikipedia , lookup

Transcript
Analog Input and Output
Rebecca Bruce and Susan Reiser, May 2015
Demo 1: Digital Output on a Breadboard
330 Ohm
resistor
•
•
Connect the blue wire to pin
13
Run File > Examples >
Basic> Blink
Rebecca Bruce and Susan Reiser, May 2015
Digital Input/Output
•
•
Digital IO is binary
valued—it’s either on or
off, 1 or 0
Internally, all
microprocessors are
digital, why?
1
0
Rebecca Bruce and Susan Reiser, May 2015
IO Pins
Image from Theory and Practice of Tangible User Interfaces at UC Berkley
Rebecca Bruce and Susan Reiser, May 2015
Demo 2: Digital Input
330 Ohm
resistor
•
Add a push-button switch to
the breadboard
- Connect the green wire
to pin 2
•
Run File > Examples >
Digital > Button
Rebecca Bruce and Susan Reiser, May 2015
Digital? Analog?
•
•
•
•
Digital has two values: on and off
Analog has many (infinite) values
Computers don’t really do analog input, they
quantize
Remember the 6 analog input pins---here’s
how they work
Image credit: Tod Kurt
Rebecca Bruce and Susan Reiser, May 2015
Variable Resistance: Potentiometers
•
It is a variable resistor
Rebecca Bruce and Susan Reiser, May 2015
Analog Input
•
•
•
Connect to analog pin A0
Run File > Examples >
Basic>
ReadAnalogVoltage
Open the serial port
monitor to see the output
Rebecca Bruce and Susan Reiser, May 2015
Analog to Digital
•
•
•
Number of states
or “bins” is the
resolution
Arduino resolution
is 10-bits (1024
values, including 0)
5/1023 = 4.9 mV
smallest voltage
change you can
measure
Image credit: Eoin Brazil
Rebecca Bruce and Susan Reiser, May 2015
Analog Output
•
Computers can’t output analog voltages
–
•
Only digital voltages (0 volts or 5 volts)
Simulating an analog signal with Pulse
Width Modulation (PWM)
–
Can’t directly supply 2.5V, but can pulse the
output on and off really fast to produce the
same effect---the same effective voltage.
Rebecca Bruce and Susan Reiser, May 2015
Analog Output
Vary the
effective voltage
by modulating
the width of
the high pulse
Image credit: Tod Kurt
Rebecca Bruce and Susan Reiser, May 2015
PWM is Everywhere
•
Lamp dimmers, motor, speed control,
power supplies, noise making, etc.
Rebecca Bruce and Susan Reiser, May 2015