Pages: [1]   Go Down
Author Topic: how to print double array values?  (Read 329 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 93
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How to print the values in a double array one at a time?

I tried this code but it doesn't work.
Code:
char input[5][8] = {
  {'1','0','8','2','9','5','3','6'},
  {'2','8','3','5','2','1','1','9'},
  {'5','0','9','2','3','1','6','0'},
  {'4','3','7','9','1','5','2','8'},
  {'8','7','3','0','0','9','1','5'}
};
void setup(){
  lcd.begin(16,2);
}
 
void loop(){
  char key = keypad.getKey();
 
  int x;
  for (x=0; x<=5;x++)
  {
    for (int y=0; y<=8; y++)
    {
      lcd.print(input[x][y]);
    }
  }
 
}


Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46265
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I tried this code but it doesn't work.
That's pretty lame, I'm afraid.

"I tried this code, and it did such and such, while I expected it to do this and that" would be much better.
Logged

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

Oh I forgot to mention what I want the output to be, sorry for that.

Consider the values in the first row in the array {'1','0','8','2','9','5','3','6'}, I want each values to be displayed one at a time in one position in the LCD say at (0,0) and to that same position only, not the next value be displayed in (1,0).
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46265
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I want each values to be displayed one at a time in one position in the LCD say at (0,0) and to that same position only
Then, you'll need to use the lcd.setCursor() method to define WHERE on the lcd to print each character.

The nested for loops don't take long to complete. Hope you can read fast. Real fast.
Logged

Aptos, California
Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't forget to add some delay to the loop so your character is readable, maybe 500 to 1000 mS.
Logged

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

I finally got it working now! thanks for the help guys.. Its time to add some codes in it.
Logged

Pages: [1]   Go Up
Jump to: