From the course: Learning Arduino: Interfacing with Hardware

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Understanding two-dimensional arrays

Understanding two-dimensional arrays - Arduino Tutorial

From the course: Learning Arduino: Interfacing with Hardware

Start my 1-month free trial

Understanding two-dimensional arrays

- [Instructor] I'm going to use the two-dimensional array concept when declaring the keypad buttons. So I'm going to go through explaining what a two-dimensional array is. Two-dimensional array that uses different columns and different rows. So this is how we write a two-dimensional array. First, we specify the type. That could be an integer, a double. Then, we declare the name that we wanted to choose for this two-dimensional array, and then, the number of rows and the number of columns. The number of rows and columns need to be an integer above zero. So here's an example of an integer two-dimensional array. I chose the name to be MyArray. That has three rows and two columns. So I initialize the array to have these values: one and two, four and five, six and seven. The way we write them within the array is that the first value are for the first row, the second set of values are for the second row, and so on. So each…

Contents