The lesson today is about arrays. An array is used when you want to
light up lights in ports that are not sequentially numbered. The
integers are declared in brackets and are identified as positions,
starting with position 0.
The first for loop identifies x being equal to the position numbers. The example above says x starts at position 0, and if x is less than or equal to position 5 (the last position shown above) than x increases by one position. This for loop is then followed by a for loop to fade lights in and fade lights out. For information about fading, see the lesson about analogWrite. Once the for loops for fading run through the first position, the loop starts over in the next position. The points listed in int woot[] are pmw ports that allow for fading. When writing additional for loops in the array (like the fading in this example) be sure to add x in the brackets for the int (int woot[x]). |