Flashing LEDs

The most important functions for this lesson can be found in the I/O section.

Also, we're going to use some loops as well as time delays to create some cool effects on the back of the phone.

Simple light

LEDs are actually all located in one array called mp.leds that has a length of 8.

The one in the upper right corner of the phone, when you turn it around, is led[0].

The number increases with the clockwise direction, meaning that the LED in the upper left corner is led[7].

LEDs also have a little bit different color library than the screen. It is called CRGB and it has many more color combinations. You can practically set your LEDs to any color you can imagine.

All these colors can be selected from the drop-down menu, so no need to keep them memorized.

Here is an example.

random image

LED cycle

Here is one example of how to set the LEDs in motion. It is really simple yet effective and it's not the only way you can do this.

random image

Having multiple for loops inside one another can often be the way of creating some cool programs. In this example, for loop is actually going through 64 cycles before it ends.

Here it allows you to turn off all the LEDs except that one you want to have turned on.

Increasing or decreasing delay() function will change the speed of alternating LEDs.