Go Down

Topic: how to print double array values? (Read 439 times) previous topic - next topic

brutal_magnet

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

I tried this code but it doesn't work.
Code: [Select]

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]);
    }
  }
 
}




PaulS

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.

brutal_magnet

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).

PaulS

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.

StanK

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

brutal_magnet

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

Go Up