Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Needed help reagarding temperature sensor LM35 code

Status
Not open for further replies.

henry15

Newbie level 3
Joined
Nov 7, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,319
Hi friends,

My project is to interface PIC16F877A with LM35 and when it gets body temperature between 37.5 Celsius to 40.0 Celsius, the led red light and buzzer should turn ON.
If the body temperature is between 36.8 Celsius to 37.5 Celsius, the led green turn on and it will check temperature every 15 minutes once....
Can anyone one help to understanding me the code for PIC....
Below this is my code....


#include <pic.h>

__CONFIG ( 0x3F32 );

#define rs RE0 // Connect pin RS to RE0
#define e RE1 // Connect pin E to RE1
#define lcd_data PORTD // Connect D0-D7 to RD0-RD7 of SB40A accordingly


void delay(unsigned long data);
void send_config(unsigned char data);
void send_char(unsigned char data);
void e_pulse(void);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void send_string(const char *s);
void loop(void);

unsigned char step=0;
unsigned char lcd_count=0;
unsigned char sequence=0;
unsigned char testbit=0x01;


//main function
void main(void)
{
// LCD main functions
ADCON1=0B00000010; //SET re0-re2 as digital output
TRISE=0B000;
TRISD=0B00000000; //set portD as output
sequence=0;

send_config(0b00001001); //clear display at lcd
send_config(0b00000010); //Lcd Return to home
send_config(0b00000110); //entry mode-cursor increase 1
send_config(0b00001100); //diplay on, cursor off and cursor blink off
send_config(0b00111000); //function

lcd_clr();
lcd_goto(0);
send_string("Patient A:");
lcd_goto(20);
send_string("Patient B:");
delay(100000);

//LED main function
TRISA = 0b00000000; //set PORTA as output
loop();
}

void delay(unsigned long data)
{
for( ;data>0;data-=1);
}


//LED functions
void loop()
{
while(1) //continuous loop
{
PORTA=0B11111111;
delay(100000);
PORTA=0B00000000;
delay(100000);
}
}


//LCD functions
void send_config(unsigned char data)
{
rs=0; //clear rs into config mode
lcd_data=data;
delay(50);
e_pulse();
}

void send_char(unsigned char data)
{
rs=1; //set rs into write mode
lcd_data=data;
delay(50);
e_pulse();
}

void e_pulse(void)
{
e=1;
delay(50);
e=0;
delay(50);
}

void lcd_goto(unsigned char data)
{
if(data<16)
{
send_config(0x80+data);
}
else
{
data=data-20;
send_config(0xc0+data);
}
}

void lcd_clr(void)
{
send_config(0x01);
delay(50);
}

void send_string(const char *s)
{
unsigned char i=0;
while (s && *s)send_char (*s++);
}
 

Did you aspect someone will spend much time to explain the whole coding? You must ask more specific question.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top