Display unsigned long value in LCD...(Solution #30 )
what want :
- read user parameter stored in eeprom. maximum value of parameter 99 sec.
- multiply 1000 convert millisecond required further computation in code.
- display converted value user decrement every loop call. relevant code segments below :
the user has entered 99 seconds. value gets displayed starts 64000 instead of 99000. think value defaulting unsigned integer - because of way storing seconds value result of atoi() function ? thought offset multiplying value 1000ul. not seeme work. tried long(cycletime). no change ...
what mistake doing ?
- read user parameter stored in eeprom. maximum value of parameter 99 sec.
- multiply 1000 convert millisecond required further computation in code.
- display converted value user decrement every loop call. relevant code segments below :
code: [select]
// variable declarations..
byte cytadd = 0 ; // eeprom address store cycle time
byte cytdata = 5; // eeprom address store machine data
char lcdmsg[17];
unsigned long cyctime, cycletime;
unsigned long loopdelay = 10;
.....
.....
.....
// storing cycletime eeprom. user edits value 4 digit number on lcd
// , results stored in 4 variables tempchar[0] tempchar[3] , following code called :
if (userkey == 'e') {
userkey = no_key;
cyctime = atoi(tempchar);
if (cyctime != 0) eeprom.put(cytadd, cyctime);
}
// code read value eeprom , convert millisecond..
eeprom.get(cytadd, cyctime ); // read stored cycle time...
cycletime = long(cyctime)*1000ul; // convert cyctime ms.
// code displaying decrementing millisecond value:
cycletime -= loopdelay;
lcd.setcursor(0, 0);
sprintf( lcdmsg, "cycle[ms]:%06ul", cycletime)
lcd.print(lcdmsg);
the user has entered 99 seconds. value gets displayed starts 64000 instead of 99000. think value defaulting unsigned integer - because of way storing seconds value result of atoi() function ? thought offset multiplying value 1000ul. not seeme work. tried long(cycletime). no change ...
what mistake doing ?
you've posted parts of code understand well. post other parts, contain problem.
Arduino Forum > Community > Gigs and Collaborations > Display unsigned long value in LCD...(Solution #30 )
arduino
Comments
Post a Comment