Pages: [1]   Go Down
Author Topic: Two Dimensional Arrays....  (Read 12181 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone know if it is possibly to have two dimensional arras on the Arduino?

Im trying to write a menu system for the LCD keypad shield.

Letting me have a list of options, that I can go deeper into... Then select something and come out again.

Anyone give me any help on this?

Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 12
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
byte my2dArray[2][3]={
  {1,2,3},
  {2,3,4}
};
smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do you access the data in an array like this?  Is it like:
my2dArray[1][1] is 3
my2dArray[0][2] is 3
my2dArray[1][2] is 4?
I'm assuming both the columns and rows are zero-indexed, but I don't know about the bracket setup.
« Last Edit: November 09, 2009, 11:43:23 pm by Ayelix » Logged

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

The best way to get an answer to your question is to fire up the IDE and start typing Serial.print statements. smiley-wink
Logged

Huntsville, Alabama, USA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 327
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How do you access the data in an array like this?  Is it like:
my2dArray[1][1] is 3
my2dArray[0][2] is 3
my2dArray[1][2] is 4?
I'm assuming both the columns and rows are zero-indexed, but I don't know about the bracket setup.
Ayelix, you have it exactly right.

Regards,

-Mike
« Last Edit: November 10, 2009, 08:51:23 am by mfm9 » Logged

Pages: [1]   Go Up
Jump to: