September 14, 2014

JBlinky Build Instructions

JBlinky is a small night light project I designed for my son's birthday party sleepover. JBlinky has a light sensor and a temperature sensor. When it is dark, the NeoPixel strip lights up, with the colour depending on the surrounding temperature. The colour changes gradually as you make it warmer or colder.

Although I did the soldering myself, the rest of the construction was done by the boys.

In terms of a party activity, I think the weak point was the final step of putting the wires in the holes on the Arduino. I had multi-strand wires, which were a little too thin to grip well in the Arduino. Perhaps a thicker single core wire would have been better for the Arduino connections.

That said, the boys had fun, and all the JBlinkies worked as expected. Here are the build instructions, just in case you have been following this project, and you want to make one yourself.

If you make one, please leave a comment to let me know how it went!

Bill of materials:
  • Arduino Uno or compatible. We used some EtherTens, because I happened to have a few spare lying around. A mini version would also work fine. This project needs 2 analog inputs, and 1 digital output.
  • 4 x AA battery holder. You could use 3 x AA, although we used 4 so that you could run the project on rechargeable batteries.
  • Adafruit NeoPixels. We used 4 from a strip of 30/m. That suits the size pretty well. Using 6 from a strip of 60/m would also work well. If you use a different number, then the code would be slightly different.
  • LM60 temperature sensor.
  • Senba light sensor. (Substitute any LDR if you like)
  • 470 ohm resistor
  • 10k ohm resistor
  • 1k uF capaitor (optional - if you are not using battery power, then I recommend this, but in the end we didn't use it in our build)
Other things:
  • Hookup wire
  • Heatshrink tubing
  • Solder
  • Soldering iron
  • Some type of box. We used a clear takeaway food container.
  • Double sided tape
  • Wire strippers
  • Wire cutters

Batteries

If using 3 x AA alkaline batteries in a 4 battery holder, place a wire between the spring of the missing battery to the spring of the 3rd battery. The exact placement of this wire will depend on how your battery holder is made, but essentially you want it to go across where the 4th battery would normally go. I soldered the wire to the 4th spring, but then just placed it between the 3rd battery and 3rd spring when the 3rd battery was inserted. This allows one end of the wire to be removed latter if you want to replace the alkalines with NiMH batteries.

Stick the back of the Arduino to the battery box with double sided tape. Make sure you can still open the battery box, and that any on/off switch is not covered up.

NeoPixels

The Adafruit NeoPixels are a great product. They have a single digital connection to send data to the whole string. Use however many you like. For my project, 4 pixels from a 30/m strip worked out at just about the right length. Using more will make your batteries run down faster.

Due to the way the NeoPixels operate the data "in" connection must go at one end. There are labels to indicate which end this is. I put a 470 ohm resistor inline for the data line to provide a bit of protection (as suggested by Adafruit).

Solder one end of the resistor to the NeoPixel strip's data input pad, and solder a wire to the other end of the resistor. (I used orange here, which will match the orange in the diagrams.)

Solder a wire to both the V+ (red) and V- terminals (black). Trim off any extra wire.


If you are going to add the capacitor (probably don't bother if you are only using battery power) then solder this directly to the NeoPixel strip (electrolytic capacitors are polarised, so solder negative to negative, and positive to positive), and then solder the wires to the protruding leads of the capacitor.

Now put some heat shrink over the resistor to cover up any exposed metal wire. If you used the capacitor (like in the photo above) then also add some heat shrink to any exposed solder joins for the red and black wires.

Let me just say that the boys LOVED the heat shrink. We used a hair dryer to shrink it.

Temperature Sensor

I used a TI LM60 analog temperature sensor in a TO-92 form. The sensor outputs a voltage that is proportional to the temperature. This makes it easy to interface to an Arduino.

The LM60 has an effective temperature range from -40 to +125 degrees. This gives the boys the opportunity to see a change between the kitchen freezer (about -15 degrees) and the hair dryer. Note that the LM60 has an accuracy of +/- 2 degrees. For a thermometer this is not very accurate, but for this project it is perfect.

Solder a wire to the middle (output) pin. I used yellow, which corresponds to my diagrams. Check the data sheet to find out which are the positive and negative pins (positive is left, when the pins face down, and the flat side faces towards you), and solder wires to the positive and negative pins. Put some heat shrink over the solder joints to reduce the chance of a short circuit.

Light Sensor

To sense the light level I used a Senba LLS05-A. I used these mainly because my supplier had them in stock, and I didn't have much time to get the prototype going before the birthday party!



I'm going to connect it in a voltage divider type circuit, so really any LDR would do.

Solder wires to the Vin (red) and Vout (green) pins. (Check the data sheet to know which is which.) If you use an LDR then they are not polarised, so you can use either pin. As with the temperature sensor, add some heat shrink over each solder joint to prevent short circuits.

Rather than put the 10k resistor inline with the light sensor I opted to make a connecting wire with the resistor inline. As I am not using a breadboard or protoboard, this makes connections easier later.

Solder wires to either end of the 10k resistor. I used green for one end and black for the other. This is because the resistor will go between the output of the light sensor (green) and ground (black).
Now put some heat shrink over the resistor.

Connections

Strip the ends of all the wires. We are going to need to connect multiple wires to a single pin on the Arduino in a number of cases. The way I did this was to add one extra connecting wire of the corresponding colour, solder together all the remaining wire ends, and connect the other end of the connecting wire to the Arduino.

Red for +5V

We will need to connect together all the +5V connecting wires, and connect that to the +5V pin of the Arduino.

Cut one more small (ish) length of red wire and strip both ends. Connect together one end of the following 4 red wires:
  • The small red connecting wire you just cut
  • The +5V wire for the NeoPixels
  • The +5V wire for the temperature sensor
  • The +5V wire for the light sensor (or LDR)
I twisted the ends of the wires together, added a blob of solder, and then got the boys to put some heat shrink over the join.

Black for Ground

We will connect together all the Ground connecting wires, and connect that to the Ground pin of the Arduino.

Cut one more small (ish) length of black wire and strip both ends. Connect together one end of the following 4 black wires:
  • The small black connecting wire you just cut
  • The Ground wire for the NeoPixels
  • The Ground wire for the temperature sensor
  • The Ground wire for the 10k resistor assembly (the black end)
Join them together as per the red wires.

Green for the light sensor

Because we want to connect the output of the light sensor to ground, this would make 2 wires going to the analog in pin. I connected the wires before the pin in a similar way to +5V and ground.

Cut one more small (ish) length of green wire and strip both ends. Connect together one end of the following 3 green wires:
  • The small green connecting wire you just cut
  • The green wire coming out of the light sensor (or LDR)
  • The green wire for the 10k resistor assembly

Programming

Here is a link to the code: JBlinky.zip

I also used the following libraries:

Plugging in


Connect the black wire (the small one coming from the connections you just joined) to the GND pin of the Arduino.

Connect the red wire (the small one coming from the connections you just joined) to the +5V pin of the Arduino.

Connect the green wire (the small one coming from the connections you just joined) to the A1 (analog 1) pin of the Arduino. This is the output of the light sensor.

Connect the yellow wire to the A0 (analog 0) pin of the Arduino. This is the output of the temperature sensor.

Connect the orange wire (coming from the 470 ohm resistor on the NeoPixels) to D6 (digital 6) pin of the Arduino. The is the input for the NeoPixels.

Connect the black wire coming from the battery box to the other GND pin, and connect the red wire coming from the battery box to the Vin pin.

Testing

The power on sequence shows a short rainbow pattern (from the Adafruit NeoPixel library test code). If you see the rainbow pattern when you switch on then you know the NeoPixels are connected correctly.

Placing the light sensor in darkness should make all the NeoPixels light up the same colour. This lets you know that the temperature sensor is connected correctly.

Once you know that the light sensor is working, with the lights on, touch the temperature sensor with your finger to warm it up. As it warms up the colour of the NeoPixels will change slightly. This lets you know that the temperature sensor is connected correctly.

If your testers have a torch/flashlight then perhaps they can use it to discover the Easter Egg mode...


Schematic

For completeness. Note that this shows the light sensor as an LDR, and it shows the LM60 as an LM36.



No comments: