ledcandlereshoot-1

“How might we make an LED candle that you can actually blow out?”

That was a question my daughter and I had one evening, so we got online and started exploring different ways to sense wind. Along the way, we discovered a pretty nifty sensor that does exactly what we needed. That sensor is the center of this project.

Concepts: Sensing Air Movement and Wind

This article is excerpted from Family Projects for Smart Objects, which contains 11 fun Arduino builds perfect for young makers. Find it at the Maker Shed (makershed.com) and fine bookstores.
This article is excerpted from Family Projects for Smart Objects, which contains 11 fun Arduino builds perfect for young makers. Find it at the Maker Shed (makershed.com) and fine bookstores.

Weather stations use a set of spinning cups, called an anemometer, to measure wind. Another way to detect air movement might be to hang two strips of tinfoil next to each other and detect when they touch, completing an electrical circuit — though that might also detect a curious cat.

There’s another method, which works on the same principle you use when your pizza slice is too hot to eat and you blow on it to cool it down. In the same way, a wire warmed up by a little electricity will cool when air blows across it — and it’s possible to measure that temperature change to sense the wind! These are called “hot-wire” wind detectors, and there’s one from Modern Device (Figure A) that plays nicely with an Arduino.

Photography by Hep Svadja
Figure A. Photography by Hep Svadja

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

Project Steps

1. ASSEMBLE THE WIND SENSOR

You need to solder the row of header pins to the sensor so you can then stick them into the breadboard.

Wait, soldering? Scary!

Not at all! Soldering is not difficult, but you do need a soldering iron, some solder, and a little lesson. Learning to solder is empowering, awesome, and easy. I like the tutorial at SparkFun, and you can find soldering Skill Builders on Make: too. This project is a great time to learn, because you need to solder just 5 spots: the 5 pins that make the “header” to stick into the breadboard. (These header pins come with the sensor board.)

The hardest part of soldering is holding everything together while you actually apply the solder to the pins. But in this case, your breadboard can be your assistant. Just push the long ends of the header pins into the breadboard and place the 5 holes at the end of the wind sensor onto the short ends. To keep the board level, place a coin between the breadboard and the other end of the sensor board.

Then solder away, making sure none of the solder from one pin touches solder from another pin. Once you have the header attached, you’re good to go

2. WIRE UP THE PARTS

Figure B
Figure B
Read articles from the magazine right here on Make:. Don’t have a subscription yet? Get one today.

Here’s the wiring diagram for this project (Figure B). It’s all plug-and-play from here, no more soldering required!

  • Insert the pushbutton at the top of the breadboard so it straddles the center canal of the breadboard and 2 of its legs are in row 1.
  • Grab the resistor, and put one of its legs into the breadboard’s column J at row 3.

NOTE: This resistor leg should be in the same row as a leg of the button. But some buttons are different sizes, and if yours has a leg in a different row, put this resistor leg in that row instead.

  • Put the other leg of the resistor in any hole along the blue negative (–) rail.
  • Grab the LED and insert its shorter leg into the column A at row 20.
  • Insert the LED’s longer leg one hole below, at column A, row 21.
  • Where the LED legs meet the breadboard, carefully bend the LED at a right angle so it’s basically “lying down” on the breadboard.
  • Insert the 5 pins of the wind sensor into the bottom 5 rows of the column A, so they’re in rows 26 through 30. The rest of the wind sensor should extend off the left side of the board, and the sensor’s GND pin should be in column A, row 30. Things should now look like Figure C.
Figure C
Figure C. Photo by John Keefe

Where’s the Resistor? You may have noticed that in most projects, we pair the sensors with a resistor. In this project, we do that again for the button (which is really a kind of sensor), but not with the wind sensor.
The reason? We’ve graduated to more sophisticated sensor boards that include not just the sensor itself but also some additional electronics — those little parts on the wind sensor board — that manage the power and send back to the Arduino just the information we need. To the extent resistors are needed, they’re already onboard. (Literally!)

Time for the jumper wires! Each step below is for one jumper wire, with the connections for both ends. The colors really don’t matter, but I’ll mention them as they match the wiring diagram in Figure B.

  • Insert one end of a (red) jumper wire into the Arduino’s 3.3V pin, and the other end into the breadboard at column H, row 1.
  • Insert one end of a (green) jumper wire into pin 2 on the Arduino’s Digital row, and the other end into the breadboard at column H, row 3. Note that this end should share a row with one of the button legs and one of the resistor legs. Again, if your button leg is in a different row, use that row instead.
  • Insert one end of a (black) jumper wire into one of the Arduino’s GND pins, and the other end into any hole along the breadboard’s blue negative rail on the right — the same rail as one leg of the resistor. This will be our “ground rail,” which will provide ground to all of the components on the breadboard.
  • Insert one end of (another black) jumper wire into the same blue negative rail on the breadboard, and the other end into column B, row 20. This is the same row as the short leg of the LED, providing ground, or the negative (–) side of the circuit, to the LED.
  • Insert one end of a (yellow) jumper wire into the Arduino’s pin 13, and the other end in the breadboard’s column B, row 21 — the same row as the longer leg of the LED.
  • Insert one end of a (red) jumper wire into the Arduino’s 5V pin, and the other end into the breadboard’s column C, row 29. Notice that that’s the same row as the sensor’s +V pin. This wire provides the power to the sensor.
  • Insert one end of an (orange) jumper wire into the Arduino’s analog pin A0, and the other end in the breadboard’s column C, row 26. This is the same row as the sensor’s TMP (temperature) pin.
  • Insert one end of a (yellow) jumper wire into the Arduino’s analog pin A1 and the other end into the breadboard’s column C, row 27. This shares a row with the sensor’s RV (raw loop voltage) pin.
  • Finally, insert one end of a (black) jumper wire into column C, row 30, and the other end into any hole in the blue negative rail on the right side — our ground rail.

The build is complete (Figure D).

electric-candle-assembled
Figure D. Photo by John Keefe

Well done!

3. LOAD THE CODE

If you’re new to the Arduino, follow their instructions to connect it to your computer.

Get the project code and click the “Copy Code to Clipboard” button.

Open your Arduino software and start a new Arduino sketch using File→New from the menu. You’ll get a mostly-blank sketch window. Delete the little code that’s there. Click anywhere inside the blank window, then paste the code you copied from the website using Edit→Paste (Figure E). Save your work using File→Save .

Figure E
Figure E

Now upload this code to the Arduino over the USB cable. You can do this from the menu, by choosing Sketch→Upload, but an even easier way is to click on the upload arrow at the top of the blue Arduino software window. You should see the “Done Uploading” message in the lower part of your Arduino window and your LED should be lit. Congratulations! You’ve just programmed your Arduino.

4. MAKE IT GO, AND BLOW!

Now whenever you power up the Arduino it will run the candle program. With the LED flickering, give a good puff across the top of the sensor (Figure F). The light should go out! Press the button on the breadboard to relight it.

Figure F
Figure F. Photo by John Keefe

To free your candle from the computer’s tether, you can plug an optional power adapter into your Arduino. You could also power the project with a 9V battery. There are some battery holders that have an Arduino adapter and a little switch. That’s important because even when the candle is out, your Arduino is still running. So remember to power it down completely with the switch (or by unplugging the battery) or you’ll run out of juice.

FIXES

The code should work to detect a good puff. If you want to make it more or less sensitive, adjust the wind speed that triggers the dousing by changing the number value in the following line from 6 to something else:

if (WindSpeed_MPH > 6) {

WHAT’S GOING ON?

As air moves across the sensor’s “hot wire” (it’s not that hot), the wire cools and its conductivity changes. The other electronics on the board detect this change and turn it into values the Arduino can read.

When these values hit our threshold, the code douses the light … and then waits for someone to push the button to relight it.

CODE CORNER

You’re a Star
There’s some serious math in the code for this project. You don’t need to know all of what’s going on, of course, but I thought it would be a good time to point out some basic math symbols.

You can probably gather that + is used for addition and  is used for subtraction.

But what about the star * ? That’s multiplication. So 2 * 3 equals 6. And / is for division. Which means 6 / 3 is 2.

In this code, there’s even a pow. That’s not comic-book slang for a punch; it’s “power,” as in “10 to the power of 2.” You might know that as 10². In Arduino, that’s written pow(10, 2). Either way, it’s 100!

Fun Functions
If you take a peek at the code for this project, you’ll see our old friends void setup() and void loop() which occur in every Arduino program.

But scroll down a bit and you’ll see they’re joined by a couple of new sections: void douseCandle() and void lightCandle(). What’s going on there? These are two functions I’ve created to perform a specific task in the code. Basically, I’ve added two commands to the existing Arduino vocabulary, joining existing commands such as analogRead() and digitalWrite().

Up in the void loop() section, I “call” these functions in a couple of different spots. One of them looks like this:

if (WindSpeed_MPH > 6) {
douseCandle();
}

When the program sees douseCandle(), it goes and looks for the function I’ve made, which is written like this:

void douseCandle() {
// turn LED off
digitalWrite(led, LOW);
}

When the function is called, the program runs the code between the function’s brackets { } — which sets the LED pin to LOW.

Functions are super useful. For one, they let you run the same block of code in many different spots. You can create a function for that code, and then just call the function whenever you need it. That way, you don’t repeat yourself — which is something coders try to abide by. They even have a name for it: DRY code (for Don’t Repeat Yourself).

TAKING IT FURTHER

ledcandlereshoot-3

In this project we’re simply interested in whether or not there’s any significant air movement across the sensor. But this little device can actually provide good data on how fast that air is moving — an actual wind speed detector. To be accurate, though, the sensor needs its own source of power, separate from the Arduino. That’s because the power running through the Arduino can fluctuate slightly, and that will affect the precise measurements of the sensor. For more information on how to wire up a separate power supply, check out the technical notes of this wind sensor.

You can also miniaturize this project to fit it into a candle-shaped enclosure. Just substitute an Arduino Nano (or other mini Arduino-compatible microcontroller), skip the breadboard, and solder the connections using hookup wire. Make: engineering intern Sydney Palmer created this cool candle (Figure G) using a cardboard tube, hot glue for the “wax” drips, and paint!

ledcandle-1
Figure G