Hey guys i am writhing code for my temp sensor (lm35) to sense temp which will be displayed on (16,2) lcd : jhd162a.
Is it necessary to give a certain amount of delay between the sensing of temp (analogread) and displaying the converted temp on lcd (lcd.write). If yes then how much delay should i give?
Long enough to verify it is not still changing. (maybe 300mS). If you get the same reading two or three times in a row with 200 to 300ms delay in between then maybe you can assume it is stable. If you only take one reading how do you know it is not increasing ?
do you have any code or reference for this particular thing sensing and displaying?
Change this :
void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
TO this:
void loop()
{
val = analogRead(analogPin); // read the input pin
lcd.println(val); // debug value
}
tried 300ms but after sometime the lcd displays unknown characters. 1000 ms is working fine but sensitivity of display for rapid temperature change obviously is bad now.
Post your code from your IDE sketch window. I think I know what's wrong.
Do you have the arduino IDE ? Do you have a sketch ? Where is your code ? Just highlight all you code and paste it into the forum post window using the "#" CODE TAGS tool button. Paste the code first , then highlight it , then click the "#" code tags button and click SAVE at the bottom.
Read my last post about the code tags.
zacmackra:
Hey guys i am writhing code for my temp sensor (lm35) to sense temp which will be displayed on (16,2) lcd : jhd162a.
Is it necessary to give a certain amount of delay between the sensing of temp (analogread) and displaying the converted temp on lcd (lcd.write). If yes then how much delay should i give?
An LM35 is not going to respond quickly to temperature changes. The ADC may not give a repeatable result for successive reads of the same temperature value so it might be a good idea to make (say) 4 successive reads and take the average. Whatever way you decide to get the value from the LM35 there is no need for a delay before the value is displayed or otherwise acted on.
...R
If you the averaging then I would agree with that.
yes you are right and i tried doing so by making a loop and read three successive readings, averaging them and then displaying but the major problem was my display was not responding well and so i cut it down. could you guys please edit my code to make it suitable for both temp measurement and display.
What is the problem with my code raschemmel?
Post a photo of your temp display on the lcd.
can't right now i have to re connect it all again but i tell you what happened ------
at first the display was not working so i put 1000ms delay and the display worked next i disconnected the arduino and tried to switch it on again and the display worked well. i then reduced the delay to 300ms and uploaded the program the display worked well and then i again disconnected the arduino and tried to switch it on again. this time the display began to show character like
$%^$ these which were moving right to left. i googled about and found that delay problem causes this as refresh rate of display is slower.
zacmackra:
can't right now i have to re connect it all again but i tell you what happened ------
at first the display was not working so i put 1000ms delay and the display worked next i disconnected the arduino and tried to switch it on again and the display worked well. i then reduced the delay to 300ms and uploaded the program the display worked well and then i again disconnected the arduino and tried to switch it on again. this time the display began to show character like
$%^$ these which were moving right to left. i googled about and found that delay problem causes this as refresh rate of display is slower.
you just tell me at what portions of my code i should put delay and how much cause i am positive it is delay problem
You may be writing to the display to frequently. Most lcd code has delays , like 1 second or so.
yes so where do i put the delay in if else loops or just after i measure the temp and threshold or both and how much.
i am giving you the raw code without any delay. Suitable changes and add delay wherever necessary.
How about we start over and you give us the ENTIRE CODE, with nothing left out.
zacmackra:
yes you are right and i tried doing so by making a loop and read three successive readings, averaging them and then displaying
On a microcontroller it is much easier to average 2, 4 or 8 readings because the division can be done with 1, 2 or 3 right shifts.
...R