Pages: [1]   Go Down
Author Topic: Displaying stored eeprom data on Parallax 2x16 Dsiplay  (Read 695 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi -

I have created a Simon game to where I am writing the high score to the eeprom (the high score is the number of rounds a user makes it though).  I have not had a problem creating the code to store the data:

Code:
  if (turn > highscore)
  {
    highscore = turn;
    EEPROM.write(0, highscore); //write highscore to eeprom
  }

The data is being stored correctly.  the problem is when I go to display the data on my Parallax LCD (27977-RT).  The code I have written is displaying the ASCII character, not the number that is stored. 

Code:
void displayhighscore() {
 
    highscore = EEPROM.read(0);
    mySerial.write(12);      //clear display     
    mySerial.print(" High Score is");  // First line
    mySerial.write(13);    // Form feed
    mySerial.print("    ");
    mySerial.write (highscore);
    mySerial.print(" rounds");   // Second line
    delay(3000);
    mySerial.write(12);                 // Clear   
    mySerial.print("Here we go...");  // First line
    mySerial.write(13);                 // Form feed
    delay(1000);
}

In other words, if the stored number in memory address is 58, the parallax displays the ":" symbol (this is the ASCII chr value for 58).

I have tried many variations using the INT , CHR  and other commands but can't seem to get "58" to display on the Parallax.

Since I'm new to Arduino  I'm sure I am making a rookie mistake.  Can someone help?
Logged

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

Code:
    mySerial.write (highscore);
write() is for sending binary data. print() is for converting binary data to strings and sending the string.

So, if highscore contains 58, write(highscore) sends the value 58, while print(highscore) sends the value "58".

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks!  I knew I was doing something stupid!

Logged

Pages: [1]   Go Up
Jump to: