Go Down

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

#### brutal_magnet

##### Oct 06, 2011, 08:04 pm
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

#1
##### Oct 06, 2011, 08:19 pm
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

#2
##### Oct 06, 2011, 08:35 pm
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

#3
##### Oct 06, 2011, 09:09 pm
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

#4
##### Oct 07, 2011, 02:06 am
Don't forget to add some delay to the loop so your character is readable, maybe 500 to 1000 mS.

#### brutal_magnet

#5
##### Oct 07, 2011, 09:01 am
I finally got it working now! thanks for the help guys.. Its time to add some codes in it.

Go Up