Offline
Jr. Member
Karma: 0
Posts: 68
|
 |
« on: January 13, 2013, 05:17:47 pm » |
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
Edison Member
Karma: 5
Posts: 2346
Do it !
|
 |
« Reply #1 on: January 13, 2013, 05:19:56 pm » |
Check out the "blink without delay" sample code in the playground.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 68
|
 |
« Reply #2 on: January 13, 2013, 05:28:04 pm » |
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
Jr. Member
Karma: 0
Posts: 68
|
 |
« Reply #3 on: January 13, 2013, 06:02:33 pm » |
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
Jr. Member
Karma: 0
Posts: 68
|
 |
« Reply #4 on: January 13, 2013, 08:02:48 pm » |
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
Brattain Member
Karma: 332
Posts: 36396
Seattle, WA USA
|
 |
« Reply #5 on: January 13, 2013, 08:18:26 pm » |
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
Jr. Member
Karma: 0
Posts: 68
|
 |
« Reply #6 on: January 13, 2013, 11:59:41 pm » |
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.  I get good ideas in the shower lol. Isn't that weird?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 68
|
 |
« Reply #7 on: January 14, 2013, 01:55:14 am » |
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.  I'll update even if no one reads. Maybe someone down the road will?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 68
|
 |
« Reply #8 on: January 14, 2013, 02:50:47 am » |
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)
Offline
Edison Member
Karma: 54
Posts: 1595
May all of your blinks be without delay
|
 |
« Reply #9 on: January 14, 2013, 03:33:22 am » |
lcd.print(temp) then lcd.print(" ") to get rid of the last digit from the previous value if it is there.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 9
Posts: 251
|
 |
« Reply #10 on: January 14, 2013, 03:41:51 am » |
Any ideas?
Not without being able to see your code 
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 68
|
 |
« Reply #11 on: January 14, 2013, 01:39:13 pm » |
Thanks guys! sending lcd.print(" ") to the right spot when temp is less than 100 is working.  I'm not near lappy but if anyone is still interested I can post code.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 68
|
 |
« Reply #12 on: January 14, 2013, 03:55:58 pm » |
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)
Offline
Edison Member
Karma: 54
Posts: 1595
May all of your blinks be without delay
|
 |
« Reply #13 on: January 14, 2013, 04:09:26 pm » |
What I actually had in mind was 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
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 68
|
 |
« Reply #14 on: January 14, 2013, 09:20:08 pm » |
Sweet!
|
|
|
|
|
Logged
|
|
|
|
|
|