i have call that temp function its reading temperature and humidity to write lcd. but my problem is i want to show values on screen 5 sec (without delay)
if i use delay(5000) its ok but all process waiting same time
what i read forum about millis and i made it but problem is not fixed
where is error ?
i have call that temp function its reading temperature and humidity to write lcd. but my problem is i want to show values on screen 5 sec (without delay)
if i use delay(5000) its ok but all process waiting same time
what i read forum about millis and i made it but problem is not fixed
where is error ?
thx br
Please use code tags when posting code. It is </>, most left formatting icon.
You changed from delay to millis, but it didn't fix the problem.
What you are saying is that all your processes still comes to a 5 seconds halt when updating LCD...?
Gabriel_swe:
Please use code tags when posting code. It is </>, most left formatting icon.
You changed from delay to millis, but it didn't fix the problem.
What you are saying is that all your processes still comes to a 5 seconds halt when updating LCD...?
thx for reply
if i use delay to last line on this function lcd show temperature and humidity for 5 sec but arduino completely freze and serial monitor not woking in that 5 sec
osezer34:
thx for reply
if i use delay to last line on this function lcd show temperature and humidity for 5 sec but arduino completely freze and serial monitor not woking in that 5 sec
Good description of delay symptom, but not an answer to my question.
Millis didn't fix the problem. Do you get the same result with millis?
thx for reply i explaining here.
from loop function millis is working properly... every 5000ms calling function
the temp function must be write HELLO to lcd but string wait on lcd for a 5000ms too
is i use delay its freezing
thx
void loop()
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 5000)
{
previousMillis = currentMillis; // Remember the time
temp();// function to temp
}
}
void temp()
{
lcd.clear();
unsigned long currentMillis= millis();
if (currentMillis - previousMillis >= 5000)
{
previousMillis= currentMillis ; // Remember the time
Serial.println(previousMillis);
Serial.println(currentMillis);
lcd.print("HELLO");
}
}
Moderator edit: CODE TAGS - why is this so hard to understand?
if (currentMillis - previousMillis >= 5000)
{
previousMillis = currentMillis; // Remember the time
temp();
}
You 'reset' previousMillis in loop(); next you call temp() and you check if the time has lapsed (which will never be the case). I think the best is to unconditionally call temp() from loop().