Hello, Hi there All,
I'm Ash, Seriously i don't know if the introduction is necessary but it is my custom introduce my self in advance.
Anyway i been using arduino for couple of years now but i still feel that i just manage to scratch the surface of its capability. all this years i have manage to make all my program using the if, if...else,switch..case, while and finally do...while. i even manage to control arduino using the bit manipulation. All this while i been dreading the fact that i don't know how to use array. To tell you the truth i been reading all kind of book on array and how to use it but in my humble of mind always manage to make a program that skip all the array in the world.
So my question in this post is really what kind of project that i can do that will make use of array and how does array help to simplify the programming stage?
Arrays are really useful, I can't imagine a program without them..or a very small and simple program maybe!
Using a for loop to set or get all values in an array or multidimensional array can be done with 2 or very few lines of code, while without arrays, the same result would be done by manually writing maybe hundreds of lines.
They are also good to keep things organizated, used in combination with enums or structs, or pointers to arrays.. Really they are like the best feature of almost any programming languages.
As for an example, I don't know...the most basic program I write would use arrays anyway
hi guix,
Yes i guess that array will simplify the program substantially but what project would you recommend? I still havent got a clue about array and i really want to know how to effectively use array in my programming. I learn by doing so please guide me.
or atleast tell me that i have the basic idea in my head?
Yes, I suggest a few changes (so you can learn even more :))
Use a global constant for the size of the array, this way if you need to modify that number, you only modify it at one place
Use a struct to organize all the data of a LED and use only one array.
i read that post b4 but i seriously didn't understand what it means but when you (guix) give your example ok now i see how it works.
i took a couple of minutes to understand your code but when i do it hit me, just think how much time i have wasted doing such long program just to achieve the same outcome