this circuit can measure the environmental temperature. It consists of LM35 temperature sensor. Atmega328 micro controller is used to read analog data from data pin of the sensor and convert the data to temperature according to the conversion factor provided in datasheet.
To make this project following components will be needed
- Atmega328 microcontroller
- crystal(16 MHZ)
- capacitor 22PF
- Seven segment display
- Matrix board
- lm35 temperature sensor
Wire up the microcontroller as follows
connect (A,B,C,D,E,F,G,Dp) of seven segment to (3,7,4,2,1,5,6,0) and enable pins (D1,D2,D3,D4) to (13,A3,A2,12) with 470 ohm resistor between each four pins. And connect the lm35 signal pin to A0 of the microcontroller. Than program the Microcontroller with following code after the circuit is complete.
#Download Sevseg library from library manager#include <SevSeg.h>
SevSeg sevseg;
float a = 0;
void setup(){
byte numDigits = 4;
byte digitPins[] = {13,A2, A3, 12};
byte segmentPins[] = {3, 7, 4, 2, 1, 5, 6, 0};
bool resistorsOnSegments = true;
bool updateWithDelaysIn = true;
byte hardwareConfig = COMMON_ANODE;
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(100);
}
void loop(){
a = (5.0 * analogRead(A0) * 100.0) / 1024;
sevseg.setNumber(a);
sevseg.refreshDisplay();
}
Above code is used to read data from the sensor convert it to the temperature value and display it on the 7 segment display. here in this code SevSeg library is used to drive the seven segment display. the library used multiplexing technique to drive the seven segment display. the benefit of using multiplexing is that even with the lesser number of output pins we can easily control large number of LED's in the display. but it also has some drawbacks. using the multiplexing will reduce the intensity of seven segment display.