文档介绍:Spooky Projects
Introduction to Microcontrollers with Arduino
Class 4
28 Oct 2006 - machineproject - Tod E. Kurt
What’s For Today
• Switches without Resistors
• All about piezos
• Building a melody player
• Using piezos as pressure & knock sensors
• Using Processing with Arduino
• Stand-alone Arduino
Recap: Programming
pile
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
Instead of this: You can just do this:
+5V
10k
to input to input
But how do you turn on these internal pull-ups?
This is sort of an aside, but it saves a lot of wiring.
Switches w/o Resistors
Answer: use digitalWrite(pin,HIGH) on the input
Arduino
board
pin 7
pin 6
pin 5
gnd
A B C
Seems a little counter-intuitive,
think of it as setting the default value of the input
but note, it doesn’t work the other way: you can’t set it to LOW then wire the switch to +5V.
Switches w/o Resistors
Can make a button box easily
if no resistors are needed
Plugs right into Arduino board
=
A B C
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 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
• Two wires, red & black.
Polarity matters: black=ground
• Apply an oscillating voltage to
make a noise
• The buzzer case supports the
piezo element and has
resonant cavity for sound
Oscillating voltage alternately squeezes and releases the piezo element.
Must apply flucuating voltage, a steady HIGH or LOW won’t work.
diagrams from: /
What’