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.

PIC16f877a using LM35 to turn the fan***plz help***almost finished

Status
Not open for further replies.
hi everyone
i want to display the temperature and intensity of light in LCD(16*2) using pic16f877a, LM35 and LDR
my project is almost completed, the temperature is displayed in LCD also light but there are some problems I encountered
first is I want to turn on the fan (I used LED for indicator) if the temp goes above 27 degree and also I want to turn on the lamp while darkness is , I have wrote the if else but it does not working another problem is the value of intensity of light is not the real value as I simulating with Proteus.
thanks plz help me to finish this project
 
Do you need to rewrite LIGHT= and TEMP=, looks like you update the numbers, maybe take them out of the while loop.
What are the max & min values for the Temp and Light?
Do you need a delay in your read_adc routine?
Is 'while' inside a 'while' valid??
I haven't done this in a while but these things stick out to me.hth.
 
thanks for replaying

here is my code :



//sensor B
ADCON0=CHANNEL1; //CHANNEL0=0b10000001

lcd_goto(28);

read_adc();

temp=read_temp();
dis_num(temp *0.48876);
// send_char('.');
// dis_num((temp%10)*(0.48876));
send_char(0b11011111);//I have found that this syntax is for make degree celecius
send_char('C');
send_char(' ');
send_char(' ');

temperature=temp; // EDIT HERE!!!!

if(temperature>27)
{
fan=1;
}

else
{
fan=0;
}

Try it with
temperature = temp *0.48876;
 
Last edited:
The Lm35 reads in Celsius
The LM35 series are precision integrated-circuit temperature
sensors, whose output voltage is linearly proportional to the
Celsius (Centigrade) temperature

Linear + 10.0 mV/˚C scale factor

So whats is this for temperature = temp *0.48876
 
The Lm35 reads in Celsius


Linear + 10.0 mV/˚C scale factor

So whats is this for temperature = temp *0.48876

I think the scaling's OK.

Full scale = 1023 corresponding to 5V. For this instance,

27˚C would give a reading of 1023 * 0.27 / 5 = 55.242

55.242 * 0.48876 = 27 (as required).

The conversion factor is 5 / (1023 * 0.01) = 0.48876
 
hi every one thanks alot for your help

yes actually I tried the temperature= temp*0.4...
and it works well thanks for explaining
but the LDR still has problem
the value of LDR is not actual value which LCD displays...
any suggestion for this?
thanks again
 
... the LDR still has problem
the value of LDR is not actual value which LCD displays...
any suggestion for this?
thanks again

What is the type no./manufacturer of the LDR (or can you link to a datasheet)? What do you want the display to show? How is the LDR connected to the PIC?

More information, please.
 
i want to show the intensity of light and also if there is darkness , then LED must be activated

I connect the VCC to LDR then LDR to 3.4 kohm resistor and then resistor to ground, the junction of resistor and ldr is going to AN0 of PIC as you can see in the codes.
any suggestion ?
 
I connect the VCC to LDR then LDR to 3.4 kohm resistor and then resistor to ground, the junction of resistor and ldr is going to AN0 of PIC as you can see in the codes.
any suggestion ?

Try replacing the LDR with another 3.4K resistor. This should give you a half-scale reading. Do you get a value displayed with that substitution?
 
actually i tried different value of resistor and the value of LDR has changed
but I think there should be some formula for calculating the value of resistors which is connected to LDR ...
thanks for ur help
 
... I think there should be some formula for calculating the value of resistors which is connected to LDR ...
thanks for ur help

If you look at page 2 of the LDR datasheet you'll get what you need to calculate a reasonable value for the resistor. Use the table as a guide for the illuminance (the "lux"), depending on your typical lighting conditions - e.g. for indoor artifical lighting, you'd have ~10 to 100 lux, while for outdoor daytime you could say ~1,000 - 10,000 lux. Next, use the graph to find what resistance range you can expect from the LDR. Choose the resistor somewhere in the middle of this range.

You may need to try different resistor values when you test the "real" circuit, but this should get you started.
 
Status
Not open for further replies.

Latest threads

Back
Top