Arduino Thermometer With 7-Segment LED
Arduino Thermometer With 7-Segment LED
Introduction
This report presents the implementation of a temperature measurement system that
incorporates the Arduino UNO microcontroller, simply referred to here as the Arduino.
The first part of this project presented in this report was implemented using a
temperature sensor and made use of two 74HC595 shift register integrated chips paired
with LED’s to display the temperature. To accomplish this, the temperature sensor provided
an analog input to the Arduino to then be processed by the pair of shift registers outputting
to the LED’s.
The console output displayed in Figure 2 below shows that the temperature sensor itself
worked accurately, reading the current temperature in the office.
Figure 3 below shows the actual circuit with the temperature sensor wired correctly
with the resistor. Adding the resistor kept the temperature sensor from overheating.
Figure 3. Actual Circuit + Temp Sensor + 10kΩ Resistor
Οι 2 shift registers που χρησιμοποιούνται είναι οι 74HC595 και το manual τους δίνεται στο
αρχείο: 74HC_HCT595-1.pdf.
Η αντιστοιχία των Pins για τον πρώτο (αριστερό) shift-register που συνδέεται στο αριστερό
digit είναι:
Q0 → DP (4)
Q1 → a (16)
Q2 → b (15)
Q3 → c (3)
Q4 → d (2)
Q5 → e (1)
Q6 → f (18)
Q7 → g (17)
Η αντιστοιχία των pins για τον δεύτερο (δεξιό) shift-register που συνδέεται στο δεξιό digit
είναι:
Q0 → DP (9)
Q1 → a (11)
Q2 → b (10)
Q3 → c (8)
Q4 → d (6)
Q5 → e (5)
Q6 → f (12)
Q7 → g (7)
Τα pins 13 και 14 του 2xdigit 7-segment display MAN6940 συνδέονται στη γη.
Η έξοδος (pin 9) serial data output του πρώτου (αριστερού) shift register 74HC595
συνδέεται με την είσοδο (pin 14) serial data input του δεύτερου (δεξιού) shift register
74HC595.
To pin 8 των 74HC595 στη γη.
To pin 16 των 74HC595 στα 5V.
To pin 13 των 74HC595 στη γη.
To pin 10 των 74HC595 στα 5V.
To pin 14 του αριστερού 74HC595 στο digital pin 11 του Arduino.
To pin 11 του αριστερού 74HC595 στο digital pin 12 του Arduino και στο pin 11 του δεξιού
74HC595.
To pin 12 του αριστερού 74HC595 στο digital pin 8 του Arduino και στο pin 12 του δεξιού
74HC595.
Το pin 9 του δεξιού 74HC595 και τα pins 15 και των δύο 74HC595 είναι στον αέρα.
Παράλληλα με τους ακροδέκτες γης και τροφοδοσίας του αισθητήρα θερμοκρασίας LM35DZ
συνέδεσα αντίσταση 10 kΩ, για να μην υπερθερμανθεί και καεί.
http://www.arduino.cc/en/Tutorial/ShiftOut
http://www.danielandrade.net/2008/07/05/temperature-sensor-arduino/
http://electro-nut.blogspot.gr/2009/07/arduino-based-temperature-display.html
int val = 0; // variable to store the value coming from the sensor
int lm35Pin = 0;
int DEBUG = 1;
// set up
void setup() {
if(DEBUG) {
Serial.begin(9600);
}
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
// Main loop
void loop() {
#ifdef _TEST_MODE
countDown();
#else
// read the value from LM35.
// read 10 values for averaging.
val = 0;
for(int i = 0; i < 10; i++) {
val += analogRead(lm35Pin);
delay(500);
}
// convert to temp:
// temp value is in 0-1023 range
// LM35 outputs 10mV/degree C. ie, 1 Volt => 100 degrees C
// So Temp = (avg_val/1023)*5 Volts * 100 degrees/Volt
float temp = val*50.0/1023.0;
int tempInt = (int)temp;
//float tempf = (temp * 9)/ 5 + 32;//converts to fahrenheit
//int tempInt = (int)tempf;
displayNum(tempInt);
The Circuit
1. Turning it on
Make the following connections:
This set up makes all of the output pins active and addressable all the time. The one flaw of this set up is that you end up with the
lights turning on to their last state or something arbitrary every time you first power up the circuit before the program starts to
run. You can get around this by controlling the MR and OE pins from your Arduino board too, but this way will work and leave you
with more open pins.
2. Connect to Arduino
From now on those will be refered to as the dataPin, the clockPin and the latchPin respectively. Notice the 0.1"f capacitor on the
latchPin, if you have some flicker when the latch pin pulses you can use a capacitor to even it out.
3. Add 8 LEDs.
In this case you should connect the cathode (short pin) of each LED to a common ground, and the anode (long pin) of each LED to
its respective shift register output pin. Using the shift register to supply power like this is called sourcing current.Some shift
registers can't source current, they can only do what is called sinking current. If you have one of those it means you will have to
flip the direction of the LEDs, putting the anodes directly to power and the cathodes (ground pins) to the shift register outputs.
You should check the your specific datasheet if you aren"t using a 595 series chip. Don"t forget to add a 220-ohm resistor in series
to protect the LEDs from being overloaded.
Circuit Diagram
The Code
Here are three code examples. The first is just some "hello world" code that simply outputs a byte value from 0 to 255. The second
program lights one LED at a time. The third cycles through an array.
The code is based on two pieces of information in the datasheet: the timing diagram and the logic table. The logic table is what tells
you that basically everything important happens on an up beat. When the clockPin goes from low to high, the shift register reads
the state of the data pin. As the data gets shifted in it is saved in an internal memory register. When the latchPin goes from low to
high the sent data gets moved from the shift registers aforementioned memory register into the output pins, lighting the LEDs.
Code Sample 1.1 Hello World
Code Sample 1.2 One by One
Code Sample 1.3 Two shift registers
Example 2
In this example you'll add a second shift register, doubling the number of output pins you have while still using the same number
of pins from the Arduino.
The Circuit
W E L C O M E
I am an electronics hobbyist based in India. Recently, I rediscovered my childhood passion in tinkering with electronic circuits. I created
this blog to share some of my projects, as well as provide some useful information to other hobbyists in India, where many electronic
components are hard to find.
Please note that the projects as well as code in this blog are provided "as is", with no guarantees. Working with electricity, electronic
components, soldering irons, etc. requires safety precautions - please use your common sense.
Good luck with your projects, and above all, have FUN!
MV
THU R SD AY, JU LY 9, 2 0 0 9
This project is part of a bigger project of mine, and it displays the ambient temperature on a set of 2 Common Cathode 7-Segment LED
displays. The temperature sensor is the LM35 IC, which outputs voltage calibrated to degrees centigrade.
The LM35 is connected to the analog input of the Arduino board. The code running on Arduino then averages 10 temperature readings to
reduce jitter, and then outputs the 2 digit integer temperature value to the 7-Segment display. To achieve the latter, it uses a set of 2 shift
registers (IC 74HC595). This is a technique that minimizes the number of output pins required by Arduino to drive the display. You can
http://www.arduino.cc/en/Tutorial/ShiftOut
Code
The following code shows how to read the analog input from the LM35 and use shiftOut() to send data to IC 74HC595. There is also an
optional countDown() method here which runs down from 99 to 0, for testing.
/*
* TempDisplay
* by MV - http://electro-nut.blogspot.com/
*
* Displaying ambient temeprature on a 2 x Common Cathode 7-Segment Displays
* Using 74HC595 shift register and the shiftOut() built in function
* Using LM35 to sense temperature.
*
* REFERENCES
*
* http://www.arduino.cc/en/Tutorial/ShiftOut
*
*/
int val = 0; // variable to store the value coming from the sensor
int lm35Pin = 0;
int DEBUG = 1;
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;
// set up
void setup() {
if(DEBUG) {
Serial.begin(9600);
}
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
// Main loop
void loop() {
#ifdef _TEST_MODE
countDown();
#else
// read the value from LM35.
// read 10 values for averaging.
val = 0;
for(int i = 0; i < 10; i++) {
val += analogRead(lm35Pin);
delay(500);
}
// convert to temp:
// temp value is in 0-1023 range
// LM35 outputs 10mV/degree C. ie, 1 Volt => 100 degrees C
// So Temp = (avg_val/1023)*5 Volts * 100 degrees/Volt
float temp = val*50.0/1023.0;
int tempInt = (int)temp;
displayNum(tempInt);
Conclusion
There is not much original here, the Arduino page on ShiftOut pretty much explains everything.
As you can see above, the temperature does change.(But don't try this and burn down your IC or worse, your house!)
References
http://www.arduino.cc/en/Tutorial/ShiftOut
http://www.facstaff.bucknell.edu/mastascu/elessonshtml/Sensors/TempLM35.html
POSTED BY MV AT 6:48 AM
ARDUINOELECTRONICSENGINEERINGHARDWAREHOWTO
Jul 5, 2008
DanielAndrade
112 Comments
Hello people, it’s been a while since I have posted projects on this website. This semester was really busy, I didn’t have time to much else,
but soon I will have my winter holiday (Here in south our summer holiday is from December to February).
Today I am going to show you how to build a simple temperature sensor using one LM35 Precision Temperature Sensor and Arduino,
so you can hookup on your future projects. The circuit will send serial information about the temperature so you can use on your
computer, change the code as you will. I’m planning to build a temperature sensor with max/min + clock + LCD, and when I get it done, I
will post here.
Parts:
• Arduino (You can use other microcontroller, but then you will need to change the code).
• LM35 Precision Centigrade Temperature Sensor, you can get from any electronic store. Here is theDATA SHEET.
• BreadBoard
Assembling:
This is a quick and simple step. Just connect the 5V output from arduino to the 1st pin of the sensor, ground the 3rd pin and the 2nd one,
you connect to the 0 Analog Input.
Down goes some pictures that may help you, click to enlarge:
Here is the Arduino Code, just upload it and check the Serial Communication Option.
You can also download the .pde HERE.
/*
An open-source LM35DZ Temperature Sensor for Arduino. This project will be enhanced on a regular
basis
(cc) by Daniel Spillere Andrade , http://www.danielandrade.net
http://creativecommons.org/license/cc-gpl
*/
int i;
void setup()
void loop()
delay(1000);
Serial.print(tempc,DEC);
Serial.print(tempf,DEC);
Serial.print(maxi,DEC);
Serial.print(mini,DEC);
Serial.println(" Min");
tempc = 0;