Pages: [1]   Go Down
Author Topic: Need a better way to slow down input to lcd other then delay()  (Read 826 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I'm using max31855 with k type tc to display temp on lcd. My original code uses delay(1000); after showing the value from the tc to slow it down a bit.

My problem is now that I have other things going on and that extra 1 second delay is messing it up. Is there any better way to do this without delaying the whole void loop()?  I wouldn't even know what to search for.

Thanks guys!

Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Check out the "blink without delay" sample code in the playground.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good call. I meant to say output haha! I try to search first but not sure what to search for sometimes. Thanks alot!
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi again,

I tried it and its working although the temp is blinking on on the lcd instead of updating every second. I'll check it more when I get home tonight.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I came up with most elegant solution but haven't tested yet. Don't mind case on phone it sucks.

Int loopcounter =0;

If loopcounter=10

LCD.print(temp)
Loop counter=0

Else

Loop counter =loopcounter + 1

You get the idea. Stupid phone argh...






Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Depend on where you put that code, loopcounter could increment from 0 to 10 in nothing flat. On the other hand, loopcounter may never increment past 1.

I'd suggest that you need to try again. The millis() function could prove useful.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I should have waited until I got home to PC. Typing code with phone sucks... Glad you kinda got where I was going with it.

My idea above is to basically have a counter that increments by 1 every time the loop runs then when the counter reaches whatever number it will update the lcd with what I want and clear the counter.  I'm going to test after a few beers but I'm sure it'll work.

Its actually working just fine now but the sketch updates the info on the lcd too fast. Slowing it down like this should be cake. I will update this thread and thanks for your reply.  smiley

I get good ideas in the shower lol. Isn't that weird?

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, its working just like I thought but there's another problem. When input temp reaches over 100 it works fine. When it goes back down the extra character after the two spaces stays there. I tried to fix it... Looks like maybe I'll be going another route. It looked perfect though with counter only at 5. Temp was updated around every second or so. Maybe a little faster but it looked perfect. smiley

I'll update even if no one reads. Maybe someone down the road will?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, same problem with millis() function as blink without delay sketch.... Updates LCD just fine every second but clears the characters....

EDIT:I'm a noob that's what happening hahahaha! I had an lcd.clear() in the void loop. The same thing is happening with every different way of doing it. Ends up being extra characters on the display after output to lcd is < 100. Say old temp was 118 and next temp was 88. Display shows 888. Its hard being a noob lolol.

I used my original code and got rid of the lcd.clear() in the void loops and it acts exactly like it did with all the other tries after removing it(lcd.clear).

Any ideas?
« Last Edit: January 14, 2013, 03:24:20 am by noobdude » Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 109
Posts: 4092
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

lcd.print(temp) then lcd.print(" ") to get rid of the last digit from the previous value if it is there.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any ideas?
Not without being able to see your code smiley-wink
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys! sending lcd.print(" ") to the right spot when temp is less than 100 is working. smiley

I'm not near lappy but if anyone is still interested I can post code. 
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A very cool member pointed out a much better way to do it. Simply clear where the extra character would be every time temp is printed. Looks great.

     lcd.setCursor(19, 4);
     lcd.print(" ");
     lcd.setCursor(17, 4);
     lcd.print(temp);

NICE!

Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 109
Posts: 4092
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What I actually had in mind was

Code:
     lcd.setCursor(17, 4);
     lcd.print(temp);
     lcd.print(" ");
No need to position the cursor before printing the space. This will work as long as temp has 2 or 3 digits.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sweet!
Logged

Pages: [1]   Go Up
Jump to: