Intro
The Parallax WS2812B REG LED Module is a whole lot of color in a tiny little package! With its 24-bit color capability, you have more than 16 million colors to play around with.
This started out as a demo of the WS2812 RGB LED kit from Parallax, but morphed into a practical use of it displaying temperature using color. The video above gives an overall demonstration of this tutorial, while the following describes how to build this demo.
This project starts you off with the basics. You’ll learn how to make your LED display one of five programmed colors depending on the temperature recorded using your temperature sensor. In this case, you’ll see either Blue, Yellow, Green, Orange, or Red.
What’s Needed:
- (1) Propeller Activity Board (#32910 or #32912)
- (1) WS2812B RGB LED + (2) 3-pin headers (#28085)
- (1) LM34 Temperature Sensor (#604-00011)
- Jumper Wires
Optional:
- (1) Parallax 2×16 Serial LCD (#27977), to display temp data
Assembly
Assembling this project is simple. First, you should start by soldering on the two 3-pin headers to your RGB LED module (they were included with the LED module).
Try to setup your soldering station so that your headers are secured in place as you work, like shown in Figure 1.
NOTE: Do not use a breadboard to keep the headers in place while you solder; it will melt the plastic.
Once the RGB LED module is soldered, open the schematic that was included with the project download and set up the circuit on your Activity Board. If you prefer working from an image rather than a schematic, Figure 2 shows the completed circuit.
The Activity Board has an on-board ADC, which greatly simplifies the connections for this project. As per the schematic, you can see that the LM34 Temperature Sensor gets connected to 5V and GND, and the output goes to the channel 0 ADC input on the Activity Board (see Figure 3 / Figure 4).
P11 connects to the LED SI pin, and it gets 5V and GND connections as well. Again, see the schematic or Figure 2 for specifics.
Optional: You can connect a 2×16 Serial LCD to your project, as mentioned in the parts list. Nothing needs to be added to the code to run the LCD, but make sure to pay attention to which pin you connect it to. If you do not use the header pins shown in the image above (P15), you’ll need to update your code with the new pin value you chose.
Programming
Open the code included in the project download and try it out. Recheck your connections if you don’t get the expected result. The LM34 is a temperature sensor designed to output 10mV per degree F. That voltage is fed into the ADC on the Activity Board and an object is used to read the value from that ADC, which will be between 0-4095 for a 0-5V input.
At 5V, the resolution for the ADC is 0.001221 volts per count from the ADC. Since we don’t want to deal with floating point math we have multiplied the count from the ADC by 1221 and then moved the decimal point 6 places to the left by dividing the result by 1,000,000. This gives us the exact voltage going into the ADC and lets us obtain the temperature from that value as well. The count, temperature and ADC voltage can be displayed on an optional 2×16 Serial LCD which is also useful for setting the temperatures used in the case statement for each color.
Modifications
You don’t need 5 color values for the ranges, if you want to simplify the output you can choose to use three instead. Simply remove the “yellow” and “orange” sections in the code (see Figure 6).
Remember that if you remove colors in the project (or add in colors, if you’d prefer), you need to adjust the temperature ranges for “blue”, “green” and “red” so that there are no gaps or overlaps in the range (0..65, 66..67, etc).
In other words, you don’t want to have the “blue” range end at 65 and the “green” one begin at 65 or it will always use the first match it finds. Likewise if “blue” ends at 65 and the next color begins at 67 when the temperature is 66 the case statement will use the “other” range and set the LED to black, which effectively turns it off.
This project could also be modified to be used as a water-temperature sensor. If you externally connect the temperature sensor so that it could be submerged or connected to a probe (being careful not to directly expose your Activity Board to water, or any of its connected components/power source to water), you could record and display temperatures for bathtubs or pool water, or even for solid surfaces. See the LM34 data sheet for operating temperature limits, and the application notes in the datasheet for details on attaching probes. Depending on the length of your probe you may need to add a capacitor to your circuit.
THIS ARTICLE IS STILL BEING RECOVERED AND RESTORED. PLEASE CHECK BACK LATER! Why is the article being recovered?
Resources
Discuss this tutorial on Savage///Chats
Released under MIT License
Copyright (c) 2004 Chris Savage – Savage///Circuits.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
PLEASE FEEL FREE TO LEAVE YOUR COMMENTS, QUESTIONS, SUGGESTIONS OR FEEDBACK ON THIS POST.
Leave a Reply
You must be logged in to post a comment.