Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Interfacing Temperature sensor with lcd

Status
Not open for further replies.

johnjameson

New Member
Heys guys,I currently building a lm35 temperture sensor and want to display my results on a lcd,I programming a mcd9000 board(with an onboard a/d converter) using keil uvision and just have a few questions
I think I have my analog to digital code set up right but the signal that saves into the AD0DAT1 register,can I manipulate that with a formula and then display on my lcd?

Below is my code(ignore he lcd parts)
# include <REG935.H>

//LCD commands
#define FunctionSet 0x3B
#define DisplayOn 0x0E
#define EntryModeSet 0x06
#define ClearScreen 0x01
#define SecondLine 0xC0

//function prototypes
void lcd_write(unsigned char display_data);
void delay(unsigned char x);
void delay_5msec();

//pin definitions
sbit EN = P2^2;
sbit RS = P2^1;
sbit RW = P2^0;

void main()
{

P2M1=0x00; //output
P2M2=0x00;

P1M1=0x00; //lcd
P1M2=0x00;

P0M1=0xFF; //set as input for sensors
P0M2=0x00;

RW = 0;
RS = 0;
lcd_write(FunctionSet);
lcd_write(DisplayOn);
lcd_write(EntryModeSet);
lcd_write(ClearScreen);


ADINS=0x02; //set ad01(P0.0) for sampling
ADCON0=0X04; //ADC channel 0 enabled
ADMODB=0x40; //sets to divide by 3,for accuracy
ADMODA=0x02; //fixed channel,continous conversion,until terminated by user

while(1)
{
int t;
ADCON0 |= 0x01; //start conversion,immediate start mode
while((ADCON0 & 0x08) == 0); //wait for end of conversion
ADCON0 &= 0xF7; //clear EOC flag
t = AD0DAT1; //display result on port 2 LEDs
lcd_write(ClearScreen);
lcd_write(t);
}
}
 
What temperature range are you trying to display?
What is the reference voltage for your A/D converter?
 
What temperature range are you trying to display?
What is the reference voltage for your A/D converter?

Well the LM35 specs say it can measure -55° to +150°C range but right now I just want to display anything on the lcd.
I've been simulating 5 volts coming into the A/D converter.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top