MicroPython Cookbook
上QQ阅读APP看书,第一时间看更新

Controlling LEDs

In this chapter, we will introduce several methods of controlling the range of NeoPixel LEDs that come with the Adafruit Circuit Playground Express. In these recipes, we will examine various ways of setting the colors of the pixels, each with its own trade-off.

We will also demonstrate how to time operations so that fades and other light animation effects can be created. NeoPixels are a powerful way of allowing a richer visual interaction with your projects. These recipes will provide you with the necessary building blocks to incorporate these visual concepts into your own projects.

In this chapter, we will cover the following recipes:

  • Turning on the pin 13 LED
  • Setting the brightness of the NeoPixel
  • Controlling the color of a single NeoPixel
  • Displaying an LED color using the RGB and hex code
  • Setting an LED color using color names
  • Setting all NeoPixels to the same color
  • Setting a range of NeoPixels to one color
  • Generating random NeoPixel LED colors
  • Creating LED animations with random colors
  • Creating LED animations with rainbow colors