Back to Arduino Step By Step Course

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

If you don't like to see ads while video is being played you can purchase this course for $200 from Udemy or purchase YouTube premium Here

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.


 /*
 * 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: https://youtu.be/YuGJpFeoq5I
 * 
 * Written by Ahmad Shamshiri on October 20, 2019   at 14:58
 * in Ajax, Ontario, Canada. www.robojax.com
 * 
 * 
 * 
 * Get this code and other Arduino codes from Robojax.com

If you found this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon http://robojax.com/L/?id=63

or make donation using PayPal http://robojax.com/L/?id=64

 *  * 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 Robojax.com
    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
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    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 <https://www.gnu.org/licenses/>.
 */

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



void setup() {
  Serial.begin(9600);
  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() {
//robojax.com loop has nothing.
  
}//

   

The least I expect from you is to thumb up the video and subscribe to my channel. I appriciate that. .I have spent months making these lectures and writing code. You don't lose anything by subscribging to my channel. Your subscription is stamp of approval to my videos and more people can find them and in it turn it helps me. Thank you

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