manjunathreddy036
Newbie level 3
interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment display
Here I am using the lm35 temperature sensor with 8051 using adc0804 to display 2 digits temperature data in 2 seven segment display.
i coulnot find the error either in the circuit or the source code. can u plz help me out with correction in circuit and code in c language..?
the circuit image is attached, plz rectify me the error in circuit and the code.
if the code is wrong plz provide me the correct code to the circuit.
Here I am using the lm35 temperature sensor with 8051 using adc0804 to display 2 digits temperature data in 2 seven segment display.
i coulnot find the error either in the circuit or the source code. can u plz help me out with correction in circuit and code in c language..?
Code:
program:
#include<reg51.h>
#define adcport P1
sbit cs=P3^7;
sbit rd=P3^6;
sbit wr=P3^5;
sbit intr=P3^4;
sbit en1=P3^0;
sbit en2=P3^1;
void conv();
void read();
unsigned char adcvalue;
void main()
{
en1=1;
en2=1;
while (1)
{
conv();
read();
if(P1=0x06)
{P0=0x06;
P2=0x4f;}
if(P1=0x07)
{P0=0x06;
P2=0x66;
}
if(P1=0x08)
{
P0=0x06;
P2=0x6d;}
if(P1=0x09)
{
P0=0x06;
P2=0x07;}
if(P1=0x0a)
{
P0=0x06;
P2=0x6f;}
if(P1=0x0b)
{
P0=0x5b;
P2=0x06;}
if(P1=0x0c)
{
P0=0x5b;
P2=0x4f;}
if(P1=0x0d)
{
P0=0x5b;
P2=0x6d;}
if(P1=0x0e)
{
P0=0x5b;
P2=0x07;}
if(P1=0x0f)
{
P0=0x5b;
P2=0x6f;}
if(P1=0x10)
{
P0=0x4f;
P2=0x3f;}
if(P1=0x11)
{
P0=0x4f;
P2=0x5b;}
if(P1=0x12)
{
P0=0x4f;
P2=0x66;}
if(P1=0x13)
{
P0=0x4f;
P2=0x7d;}
if(P1=0x14)
{
P0=0x4f;
P2=0x7f;}
if(P1=0x15)
{
P0=0x66;
P2=0x3f;}
if(P1=0x16)
{
P0=0x66;
P2=0x5b;}
if(P1=0x17)
{
P0=0x66;
P2=0x66;}
if(P1=0x18)
{
P0=0x66;
P2=0x7d;}
if(P1=0x19)
{
P0=0x66;
P2=0x7f;}
if(P1=0x1a)
{
P0=0x6d;
P2=0x3f;}
if(P1=0x1b)
{
P0=0x6d;
P2=0x5b;}
if(P1=0x1c)
{
P0=0x6d;
P2=0x66;}
if(P1=0x1d)
{
P0=0x6d;
P2=0x7d;}
if(P1=0x1e)
{
P0=0x6d;
P2=0x7f;}
if(P1=0x1f)
{
P0=0x7d;
P2=0x3f;}
}
}
void conv()
{
cs = 0;
wr = 0;
wr = 1;
cs = 1;
while (intr);
}
void read()
{
cs = 0; //Make CS low
rd = 0; //Make RD low
adcvalue= adcport; //Read ADC port
rd = 1; //Make RD high
cs = 1; //Make CS high
}
the circuit image is attached, plz rectify me the error in circuit and the code.
if the code is wrong plz provide me the correct code to the circuit.
Last edited by a moderator: