0% found this document useful (0 votes)
124 views8 pages

Aim of Experiment: Write A Program To Read Temperature From Sensor (LM35) and Display It in LCD

This document describes a program to read temperature from an LM35 temperature sensor and display it on an LCD screen. The program uses an ATmega 32 microcontroller, LM35 temperature sensor, LCD display, and ADC to read the analog temperature sensor output, convert it to digital, and display the temperature on the LCD. The hardware and software components used are listed, including Atmel Studio and Proteus. The circuit diagram and program code are provided to initialize the ADC, read the sensor value, convert it to a numeric string, and continuously display the updated temperature on the LCD.

Uploaded by

Chandra Sekhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views8 pages

Aim of Experiment: Write A Program To Read Temperature From Sensor (LM35) and Display It in LCD

This document describes a program to read temperature from an LM35 temperature sensor and display it on an LCD screen. The program uses an ATmega 32 microcontroller, LM35 temperature sensor, LCD display, and ADC to read the analog temperature sensor output, convert it to digital, and display the temperature on the LCD. The hardware and software components used are listed, including Atmel Studio and Proteus. The circuit diagram and program code are provided to initialize the ADC, read the sensor value, convert it to a numeric string, and continuously display the updated temperature on the LCD.

Uploaded by

Chandra Sekhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

AIM OF EXPERIMENT

Write a program to read temperature from sensor (LM35) and display it in LCD.

Software Used
1. Atmel Studuio 7.0
2. Proteus Professional 8

Hardware Used
1. ATmega 32
2. Temperature Sensor (LM35)
3. LCD Display (LM016L)
4. POT-HG
Proteus Diagram
Program through ATMEL Studio
* Created: 4/30/2020 12:38:24 PM
* Author : Chandra Sekhar
*/

#define F_CPU 8000000UL //16 Mhz clock speed//


#include <avr/io.h>
#include <util/delay.h>
#define lcdport PORTB
#define signal PORTC
#define en PC2
#define rw PC1
#define rs PC0

void lcdcmd(unsigned char cmd);


void lcdint ();
void lcddata(unsigned char data);
void lcd_print(char * str);
unsigned char digit[3];
unsigned char value;
void adc_init();
void adc_conversion();
void adc_convert(unsigned char);

unsigned char
symobli[8]={0x08,0x04,0x02,0x1f,0x02,0x04,0x08,0x00};
int main(void)
{
lcdint();
adc_init();
DDRB=0xff; //output port//
DDRC =0b00011111;
lcd_print("Room Temperature");
while (1)
{
lcdcmd(0x01);
lcdcmd(0x84);
adc_conversion();
}
}
void adc_init()
{
ADMUX =(1<<REFS0);
ADCSRA = (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
//ADC enble and prerscaler of 128//
}

void adc_conversion()
{
ADCSRA|=(1<<ADSC);
while(ADCSRA & (1<<ADSC));
adc_convert(ADC/2);
_delay_ms(500);

void adc_convert(unsigned char k)


{

unsigned int g;
g=(k/10);
digit[0]=(k%10);
digit[1]=(g%10);
digit[2]=(g/10);
lcddata(digit[2]+48);
lcddata(digit[1]+48);
lcddata(digit[0]+48);
lcdcmd(0x40); //Address where first custom character

is stored//
lcddata(10);
lcddata(17);
lcddata(17);
lcddata(10);
lcddata(0);
lcddata(0);
lcddata(0);
lcddata(0);
lcdcmd(0x87); //Address on lcd where the character

is to be diplayed//
lcddata(0x00); // Display the Character cerated at
adress 0x40//
lcddata('c');

void lcdint()
{
lcdcmd(0x38);
_delay_ms(1);
lcdcmd(0x01);
_delay_ms(1);
lcdcmd(0x0E);
_delay_ms(1);

void lcdcmd(unsigned char x)

{
lcdport=x;
signal|=(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(5);
signal &=(0<<rs)|(0<<rw)|(0<<en);
_delay_ms(30);

void lcddata(unsigned char data)

{
lcdport=data;
signal|=(1<<rs)|(0<<rw)|(1<<en);
_delay_ms(5);
signal&=(1<<rs)|(0<<rw)|(0<<en);
_delay_ms(30);

void lcd_print(char * str)


{
unsigned char i=0;
while(str[i]!=0)
{

lcddata(str[i]);
i++;

}
}

Output From Proteus


Observation
The temperature sensor LM35 sense the temperature and converts in to a
voltage as calibrated , the voltage then converted to digital by ADC and
displayed on the LCD.

Conclusions
From the above experiment interfacing of LM35 sensor with ATmega 32 was
studied and for diiferent temperature LCD displaying according to that
temperature.

Submitted By
Chandra Sekhar Tripathy
Regd no. 1907106118
M.Tech PED 2nd Sem.

You might also like