Bionic Arduino: Class 2
Bionic Arduino: Class 2
Class 2
compile
upload
Rule #1 of experimenting:
schematic
Snug-fit straws on
the end of your
LEDs to make
them glow more
visibly
Random Behavior
“CandleLight”
Uses simple
pseudo random
number generator
to mimic flame
Use random(min,max) to
pick a number between min
& max.
Analog Input
To computers, analog is chunky
Analog Input
• Many states, not just two (HIGH/LOW)
• Number of states (or values, or “bins”) is resolution
• Common computer resolutions:
• 8-bit = 256 values
• 16-bit = 65,536 values
• 32-bit = 4,294,967,296 values
Analog Input
• Arduino (ATmega168) has six ADC inputs
• (ADC = Analog to Digital Converter)
• Reads voltage between 0 to 5 volts
• Resolution is 10-bit (1024 values)
• In other words, 5/1024 = 4.8 mV smallest
voltage change you can measure
Analog Input
Sure sure, but how to make a varying voltage?
With a potentiometer. Or just pot.
+5V–
50k
measure–
gnd–
RGB LED
anode +
red cathode –
anode +
blue cathode –
green cathode –
red blue green
slightly bend the longest lead and plug it into the +5v (red) bus
plug remaining leads into rows (12,14,&16 here)
connect 220 (red-red-brown) resistors across middle to matching rows
run wires from resistors to pins 9,10,11 of Arduino, can color-code if you want
RGB Color Fading
“RGBMoodLight”
schematic symbol
Photocell Circuit
pin A2
brown-black-orange
gnd
thermistor
(temperature)
photocell
(light)
flex sensor
(bend, deflection)
Click on “Serial
Monitor” button to see
output
In “Serial Monitor”,
type “H”, press Send
LOW
chip
• The “readSerialString()”
function at right takes a
character string and sticks
available serial data into it
Piezoelectrics
• Big word – piezein is greek for “squeeze”
• Some crystals, when squeezed, make a spark
• Turns out the process goes the other way too
• Spark a quartz crystal, and it flexes
• Piezo buzzers use this to make sound
(flex something back and forth, it moves air)
Piezo Buzzers
No touching needed!
We’ll use light in lieu of RF Leon Theremin
Light Theremin
“Theremin”
to Roomba
Going Further
• Piezo buzzers
• Can hook up multiple buzzers for
polyphonic sound
• Can play waves other than just square
waves using PWM techniques
• Can also be used as input devices (we’ll
cover that later)
Going Further
• Serial communications
• Not just for computer-to-Arduino
communications
• Many other devices speak serial
• Older keyboards & mice speak are serial
(good for sensors!)
• Interface boards (graphic LCDs, servo
drivers, RFID readers, Ethernet, Wi-Fi)
Going Further
• RGB LEDS
• You can pretty easily replicate
the Ambient Orb ($150)
functionality
• Make a status display for your
computer
• Computer-controlled accent
lighting (a wash of color
against the walls)
END Class 2
http://todbot.com/blog/bionicarduino/
Tod E. Kurt
tod@todbot.com