Hot_Cold-LEDs.pdf

(758 KB) Pobierz
Hot/Cold LEDs
Hot/Cold LEDs
Written By: Julius Schmiedel
PARTS:
Arduino Uno Board (1)
from RadioShack.
USB cable (1)
from RadioShack.
Parallax 'Ping' Sensor (1)
from RadioShack.
Breadboard Jumper Wires (1)
Carbon-film resistor assortment pack (1)
from RadioShack.
Super-bright Blue LED (1)
from RadioShack.
Super-bright Red LED (1)
from RadioShack.
Resistor, 56Ω, 1/4W (1)
from RadioShack.
Resistor, 150Ω, 1/4W (1)
from RadioShack.
SUMMARY
© Make Projects
www.makeprojects.com
Page 1 of 10
Hot/Cold LEDs
SUMMARY
In this project, we will combine an Arduino, a Ping sensor, and a small assortment of
components, to build a project that senses distances as "hot/cold." Once built, we'll walk
through the software running our basic "sketch," (what an Arduino program is called) and
then experiment with variations of the "hot/cold" theme, all the while using the same circuit.
For the Arduino sketch files provided, the V1 sketch is detailed below. It measures distance
from the sensor. The farther you are from the sensor, the "cold" blue LED begins to glow,
and then the closer you get to the sensor, the "cold" LED fades away and the "hot" red LED
turns up to full brightness!
The V2 sketch is a "capture the ping" game. At first, the "cold" blue LED glows, and every so
often, the "hot" red LED will flash. When the red LED is on, try to move your hand in front of
the sensor quickly. If you are fast enough, the red LED will flash; if you are too slow (or
cheat!), the blue LED will flash.
And finally, the V3 sketch is a simple "hot/cold" switch. When no object is present in front of
the sensor, the "cold" blue LED will produce a slow pulse. When it does sense an object, say
when you sit down in front of your computer, the "cold" blue LED will turn off and the "hot"
red one will shine at full brightness. This switch can be used to trigger other effects, such as
waking your computer up from sleep mode.
© Make Projects
www.makeprojects.com
Page 2 of 10
Hot/Cold LEDs
Step 1 — Gather all your components.
Believe it or not, these are all the parts you will require for this build!
NOTE: Resistors listed in subsequent steps are for the LEDs suggested in the
parts list. If you want to use different LEDs, you'll have to calculate the resistor
required using Ohm's Law. Search online for "LED calculator" to determine the resistor
needed.
The 500-pack of resistors is recommended so you always have a range of options
available.
First, connect the breadboard to the Arduino. Using two jumper wires: connect one wire
from the 5V pin on the Arduino to the power rail on the breadboard. Have the other go from
the GND pin to the ground rail.
Take a look at the Ping sensor. You‘ll notice three pins next to each other, labeled GND,
5V, and Sig (as in "Signal"). Now, let's wire up the connections necessary to supply power,
ground, and signal to the Ping Sensor.
Decide where you want your Ping sensor located on the breadboard. Make a connection
between the ground rail and the sensor's GND pin row. Add another wire between the
power rail and the sensor's 5V pin row. Alternatively, you could use short pieces of 20
AWG hookup wire.
Lastly, make a connection between the Ping sensor's Sig(nal) pin row, and the Arduino pin
labeled number 7. This connection will work in two directions: It will be used to send the
"ping“ from the sensor, and also transmit the signal coming back from an object in front of
the sensor.
© Make Projects
www.makeprojects.com
Page 3 of 10
Hot/Cold LEDs
Step 2 — Place the Ping sensor.
Place the Ping sensor on the board so that the connections line up with the wires you just
placed. Carefully check to ensure all the connections are correct. Trace the connection
from the Arduino GND pin to the ground rail, to the GND pin on the Ping sensor. Do the
same for the supply voltage.
Next, use two jumper wires which will eventually connect the LEDs to the Arduino. Place a
wire from the Arduino pin 6 to the row where you want to place your blue LED. Do the
same for the row intended for the red LED, and connect it to the Arduino pin 5.
If you‘re curious about why I left two rows empty in-between the two jumper wires
on the breadboard, that's because we need a resistor for each LED (see next step
for details). The resistor values are calculated by using the rated voltage and current of the
LED, and the voltage supplied, and Ohm's Law.
© Make Projects
www.makeprojects.com
Page 4 of 10
Hot/Cold LEDs
Step 3 — Connect the LEDs and resistors.
First, take the 150Ω resistor (brown-green-brown) and make a connection between the
ground rail and the row next to the row connected to pin 5 (driving the red LED). Using the
56Ω resistor (green-blue-black), do the same for the blue LED, connecting the ground rail
and the row next to the one connected to pin 6 on the Arduino.
All we need to do now is connect our LEDs to the board. Since LEDs, like all diodes, work
only in one direction, you have to make sure to place them so the shorter leg, called
cathode, is connected to GND through the resistor. The "positive“ side, called anode, has
the longer leg and will be connected to the Arduino via a jumper wire.
Place the red LED so the shorter leg will be connected to the resistor, and the longer leg
goes in the row which is connected to pin 5. Do the same for the blue LED, connecting its
cathode to the resistor, and the anode to the row going to pin 6 of your Arduino.
A simple visual check now will save time in the future. Trace the connections to
make sure everything is in its designated place. Once you're ready to load the
software sketches, continue to the next step.
© Make Projects
www.makeprojects.com
Page 5 of 10
Zgłoś jeśli naruszono regulamin