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.