Microcontroller Project
Microcontroller Project
Microcontroller Project
PROJECT ON
TEMPERATURE SENSING
USING LM35
AIM:
1
To indicate the temperature range using LM35 temperature sensor and to simulate the following
THEORY:
LM35 is a precision IC temperature sensor with its output proportional to the temperature (in
oC). The sensor circuitry is sealed and therefore it is not subjected to oxidation and other
processes. With LM35, temperature can be measured more accurately than with a thermistor. It
also possess low self-heating and does not cause more than 0.1 oC temperature rise in still
air. The operating temperature range is from -55°C to 150°C. The output voltage varies by
10mV in response to every oC rise/fall in ambient temperature, i.e., its scale factor is 0.01V/
oC.
Pin Diagram:
Pin Description:
PROCEDURE:
2
3. From the component library add ATMEGA 32, LM35 and LCD to the component list to be
used.
4. Place the ATMEGA 32 on the workspace and connect the LM35 to the PA1/ADC1 pin .
5. Connect the first pin of LM35 to Vcc and pin3 to ground.
6. Connect the output pin of ATMEGA 32 PA1 to D0 of lcd
7. Connect the output pin of ATMEGA 32 PA2 to D1 of lcd
8. Connect the output pin of ATMEGA 32 PA3 to D2 of lcd
9. Now code the program in ATMEGA software and load the coded program to Proteus
professional.
10. Run the Simulation.
11. The temperature of room will be diaplayed on lcd screen
CODE:
#include <avr/io.h>
#include <util/delay.h>
#define RS PB0
#define RW PB1
#define E PB2
PORTC=a;
PORTB&=~(1<<RS);
PORTB&=~(1<<RW);
PORTB|=(1<<E);
_delay_ms(1);
PORTB&=~(1<<E);
PORTC=b;
PORTB|=(1<<RS);
3
PORTB&=~(1<<RW);
PORTB|=(1<<E);
_delay_ms(1);
PORTB&=~(1<<E);
ADMUX=(1<<REFS0);
ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0)|(1<<ADATE);
a= a & 0b00000111;
ADMUX |= a;
ADCSRA|=(1<<ADSC);
return (ADC);
void STRING(int s)
int a,b,c,d;
a=s%10;
LCDCOM(0x84);
LCDDAT(a+48);
b=(s/10)%10;
LCDCOM(0x83);
LCDDAT(b+48);
4
c=(s/100)%10;
LCDCOM(0x82);
LCDDAT(c+48);
d=(s/1000)%10;
LCDCOM(0x81);
LCDDAT(d+48);
main()
DDRA=0x00;
DDRB=0xFF;
DDRC=0xFF;
DDRD=0xFF;
int b,c,q;
LCDCOM(0x38);//LCD INITALZATION
LCDCOM(0x0e);//LCD INITALZATION
ADC_init();
while(1)
ADC_read(0b00000001);
c=ADCL;
b=ADCH;
q=(c&(0x0f))+((c>>4)*16)+((b&(0x0f))*256-1);//BINARY TO DECIMAL
5
}}
SCREEN SHOTS:
RESULT: Thus we have displayed the temperature of room with atmega-32 & lm35 using proteus
professional .