Back to Step by Step Course by Robojax

Lesson 58 : What is multidimensional Array? Example of RGB LED

Please select other codes for this lecture from the links below.

Part 6: Arduino Practial Programming

In this lesson we learn about multidimensional array. Regular array is single dimension which is list of values in one variable. But when you have related values like lenght and width of objects, then we can define two dimensional array to hold lenght and width for the same object in the same index. This allows to have dimensions for example of items in a multidimensional array.
If we want for example to meausre voltage and current at different intervals of time we can use a two dimensional array. or we can use a three dimensional array two assign values of color red, green and blue for RGB LED. In the next lession we practially use it with RGB LED. Please watch the video for full details.

  • 00:00 Introduction to multidimensional array
  • 04:25 Reading value of a multidimensional array (this code)
  • 05:50 Updating value of a multidimensional array
  • 08:57 Defining 3 dimensional array
  • 10:29 Dreading 3 dimensional array values
  • 11:37 Updating 3 dimensional array values
  • 12:39 Defining empty 3 dimensional array

 * Lesson 58: What is multidimensional Array? RGB LED example
 * example from the video to print values of multidimensionalarray
 Watch video for full details of this code:
 * Written by Ahmad Shamshiri on October 20, 2019   at 14:58
 * in Ajax, Ontario, Canada.
 * Get this code and other Arduino codes from

If you found this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon

or make donation using PayPal

 *  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <>.

//defining a three dimentional array with 3 rows
int shapes[3][3] = {
		{16, 8, 9},
		{23, 10, 7},
		{41, 17, 19}

void setup() {
  Serial.print("3x3 Array");
  Serial.println(shapes[1][1]);//prints 10
  Serial.println(shapes[0][0]);//prints 16 
  Serial.println(shapes[2][2]);//prints 19
  Serial.println(shapes[2][0]);//prints 41 

void loop() {
// loop has nothing.


The least I expect from you is to give the video a thumbs up and subscribe to my channel. I appreciate it. I have spent hundreds of hours making these lectures and writing code. You don't lose anything by subscribing to my channel. Your subscription is a stamp of approval for my videos, helping more people find them and, in turn, helping me. Thank you!

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal

**** AFFILIATE PROGRAM **** We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to and affiliated sites.

Right Side