You are on page 1of 5

Temperature sensor by LM335,

for quire contact: engnr.shakeel@gamil.com

Temperature sensor by LM335,


LCD, PIC16F877A
The LM335 temperature sensor is an easy to use, cost-effective sensor with decent
accuracy (around +/- 3 degrees C calibrated). The sensor is essentially a zener
diode whose reverse breakdown voltage is proportional to absolute temperature.
Software used:
Than the micro controller read this voltage of LM35 and after calculations display on
the LCD
a. MickroC PRO
b. Proteous 7.7

BEST OF LUCK.

Engr Rana Muhammad Shakeel


Engnr.shakeel@gmail.com
+92-333-4962507
https://www.facebook.com/EngnrShakeel
plz like my page:
https://www.facebook.com/Electrical4Electronics

Engnr Rana M Shakeel, +92-333-4962507 | engnr.shakeel@gmail.com

Temperature sensor by LM335,

for quire contact: engnr.shakeel@gamil.com

Circuit Diagram

Engnr Rana M Shakeel, +92-333-4962507 | engnr.shakeel@gmail.com

Temperature sensor by LM335,

for quire contact: engnr.shakeel@gamil.com

Code:
// Program to make a Liquid
/*Header******************************************************/

level

// LCD module connections


sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

int temp;
char txt[8];
unsigned char ch;

//

unsigned int adc_rd;

// Declare variables

char *text;

//

long tlong;

//

void introduction (void)


3

Engnr Rana M Shakeel, +92-333-4962507 | engnr.shakeel@gmail.com

Temperature sensor by LM335,

for quire contact: engnr.shakeel@gamil.com

Lcd_Cmd(_LCD_CLEAR);

// LCD command (clear LCD)

text = " Tempeature ";

// Define the first message

Lcd_Out(1,1,text);

// Write the first message in the first line

text = "by PIC16F877A";


Lcd_Out(2,1,text);

// Define the second message


// Define the first message

Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
text = "Engnr Rana M";

// Define the first message

Lcd_Out(1,1,text);

// Write the first message in the first line

Delay_ms(1000);
text = " Shakeel ";
Lcd_Out(2,1,text);

// Define the second message


// Define the first message

Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
text = " Temperature ";

// LCD command (clear LCD)


// Define the first message

Lcd_Out(1,1,text);

}
void main()
{
TRISA = 0xFF;

trisB=0x00;
4

Engnr Rana M Shakeel, +92-333-4962507 | engnr.shakeel@gmail.com

Temperature sensor by LM335,

for quire contact: engnr.shakeel@gamil.com

portb=1;
adcon1=0x00;
Lcd_Init();

// LCD display initialization

Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR);
ADCON1 = 0x82;
TRISA = 0xFF;

// LCD command (cursor off)


// LCD command (clear LCD)

// A/D voltage reference is VCC


// All port A pins are configured as inputs

Delay_ms(1000);
introduction (void);
text = "Temp: ";

// Define the third message

Delay_ms(1000);
while (1) {
adc_rd = ADC_Read(0);
Lcd_Out(2,1,text);

// A/D conversion. Pin RA2 is an input.


// Write result in the second line

temp=(adc_rd - 559.567) / 2 ;
inttostr(temp,txt);

// convert integer into string

Lcd_Out(2,5,txt);
Lcd_Chr_CP('C');

// display character

Delay_ms(1);

}
}

Engnr Rana M Shakeel, +92-333-4962507 | engnr.shakeel@gmail.com

You might also like