After reading numerous books and experimenting with many tutorials, I decided it was time to apply what I had learned and create my first "from scratch" Arduino project. I wanted to keep it simple but also provide the opportunity to try out some of the new coding techniques I had learned.
I came up with the idea of a large-display thermometer that uses an array of colored LEDs to represent the traditional column of liquid. In theory, a completed project of this type could be housed in an enclosure and hung on the wall, where it would be easily readable from a distance.
Step 1: Parts I Used
1- Protoshield (optional)
1- TMP36 temperature sensor
16- 10mm, diffused-lens LEDs (blue, green, yellow, red)
16- 330 ohm, 1/4w resistors
2- 74HC595 shift register ICs
Step 2: Assembly
I was a bit concerned about the power usage in the event all 16 LEDs were lit at the same time. The 5v power output on the Arduino has a maximum rating of 500ma. Considering the resistors I chose, I estimated that the display should use less than 300ma. However, I never thought to actually measure it once the project was done. The power for each LED sinks through the pins in the shift register chips, so powering the full array from the Arduino output pins isn't an issue.
Note: The use of the protoshield is optional. You could just as easily connect the TMP36 to the breadboard (as shown in the Fritzing diagram). I just found it convenient to separate the display and sensing portions of the project.
After I had the hardware working, I devised an example template the might be put around the LEDs to indicate, along with the colors, what temperature was being sensed (PDF file)
Step 3: Arduino Sketch
I struggled with a more elegant way to code the way the temperature cutoff points for each LED would be tested, but finally conceded defeat and went with a long list of IF-ELSE IF statements. I realized that in the event all or none of the LEDs were lit, you wouldn't be able to tell if the temperature was merely at or well outside the specified limits. Therefore, there's a test that will flash either the top or bottom LED to show if the sensor reading is outside the range of the display. Finally (mostly because I like to watch flashy, LED thingys), I added a self-test of the display at power-up that lights all the LEDs in sequence.
Step 4: Conclusion
- It should be possible to add dimming control to the display by applying a PWM signal to the OE pins of the shift registers. The display brightness could then be adjusted manually with a potentiometer or automatically with a photocell.
- While this project was built to display temperature, I would think it could be adapted to display information from any type of sensor, humidity, sound or fluid levels for example.
- Perhaps someday I will revisit the ELSE IF issue. Maybe some of you expert coders out there can throw me a bone :-)