Arduino Projects
Arduino Projects
Class 4
Reset Upload
Like always, just make sure. Make “led_blink” come alive again. Do it. Trust me.
Switches w/o Resistors
AVR chip has internal “pull-up” resistors
10k
to input to input
Arduino
board
pin 7
pin 6
pin 5
gnd
A B C
=
A B C
Piezoelectrics
Piezo buzzers don’t have quartz crystals, but instead a kind of ceramic that also exhibits
piezoelectric properties.
I pronounce it “pie-zoh”. Or sometimes “pee-ay-zoh”.
Piezo Buzzers
piezo
Arduino
buzzer
board
+
pin 7
–
gnd
Piezo leads are very thin. The breadboard holes grab them better than the header sockets, which is
why the jumper leads are used.
Play a Melody
“sound_serial”
Arduino
board
10k
+
pin 7 piezo
(brown, buzzer
–
black,
orange)
gnd
Like most things in electronics, if you want less of something, add a resistor.
A better value would probably be 1k, but we don’t have that on hand.
This may not seem important now, but wait for the next project.
Play a Stored Melody
“play_melody”
No touching needed!
We’ll use light in lieu of RF Leon Theremin
As heard on Star Trek, Beach Boys, horror movies, Mars Attacks!, and bad New Age songs.
Works sorta like those touch switches, but no touching here.
That is, your body becomes a variable capacitor.
Make a Theremin
Take photocell circuit from before, bolt it on
piezo
+5V Arduino
buzzer
board
+
pin 7
photocell
analog pin 0 –
10k gnd
(brown,
black,
orange)
Okay so maybe it sounds more like a bad video game than a spooky movie
The glitchy sound is cause because of the time it takes to read the sensor
There are ways around such stuff, but requires more complex programming using timers &
interrupts
The sound can get annoying quick
Piezo Buzzer as Sensor
• Piezo buzzers exhibit the reverse piezoelectric
effect.
• The normal piezoelectric effect is generating
electricity from squeezing a crystal.
• Can get several thousand volts, makes a spark
• You probably have seen a big example of this
already:
fireplace lighter
I have a demo piezo igniter from one of these lighters. It’s fun to shock yourself.
Puts out several thousand volts. (ionization voltage of air =~ 30kV/cm)
Piezo Read
• To read a piezo you can
just hook it into an
analog input, but:
Arduino
up (brown,
black,
•
green)
You should have a
protection diode to
limit big voltages, else piezo input schematic
fry your inputs
Arduino
piezo board
buzzer
+
analog pin 0
– 5.1v
gnd
zener 1M
(brown,
black,
green)
Create two little busses for GND and A0, and hook components across it.
Black bar on diode indicates “bar” of diode.
Piezo Read
“piezo_read”
Number is “t”, the number of times it looped waiting for the value to drop below THRESHOLD/2.
How Does that Work?
• When a piezo is struck, it “rings” like a bell
• But instead of sound, it outputs voltage
• The sketch measures time above a certain
voltage, hoping to catch largest ring
volts
time
t
whack!
Depending on how fast you can watch the input, this technique works either really well or not that
well. There are much faster ways of watching inputs that loops with analogRead()
But for now it works okay
Custom Piezo Sensors
Can mount the element on anything
(floor mat, door, your body, etc.)
• Press “Run”
button
four steps
1.
1. load library
2. set portname be sure to set to
2. the same as
3. open port
4. read/write port “Serial Port” in
3. Arduino GUI
4.
Use “piezo_read”
Arduino sketch from
before
This is not to build, just quickly cover. It’s not in the handout, but,
full details at: http://todbot.com/blog/2006/10/23/diy-ambient-orb-with-arduino-update/
Fun Uses
External Power
Arduino can run off USB power or external power
External power connector USB connector
voltage
regulator
Connector is
standard barrel
connector
Voltage can be
9-15 V DC center
positive
Amps is > 200mA
Actually input voltage can be from like 7.5V to 35V, but don’t go over 15V so the voltage regulator
doesn’t have to work so hard.
External Power
Or you can use a battery
resistive sensors
switches/buttons
LEDs
piezos
fast
prototyping
servos
Summary
And you’ve learned many software building blocks
serial
communication
pulse width
modulation
analog I/O
digital I/O
+5V +5V
1N4004 1N4004
DC motor M 5V relay
Arduino Arduino
board board
1k 1k
pin 7 pin 7 to load
TIP120 TIP120
gnd gnd
motors relays
http://todbot.com/blog/spookyarduino
Tod E. Kurt
[email protected]
A little extra: MIDI
Combine everything, add a MIDI jack
Arduino
board
piezo pin 7
buzzer pin 6
pin 5
+ analog 0
pin 1
– 5.1v gnd
zener 1M A B C
MIDI jack
+5V
3 1
5 4 220
2
A little extra: MIDI
A little extra: MIDI