CircuitPython Internal RGB LED
Every board has a built in RGB LED. You can use CircuitPython to control the color and brightness of this LED. There
are two different types of internal RGB LEDs:
section covers both and explains which boards have which LED.
The first example will show you how to change the color and brightness of the internal RGB LED.
Copy and paste the code into code.py using your favorite editor, and save the file.
import time
import board
# For Trinket M0, Gemma M0, ItsyBitsy M0 Express, and ItsyBitsy M4 Express
import adafruit_dotstar
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
# For Feather M0 Express, Metro M0 Express, Metro M4 Express, and Circuit Playground Express
# import neopixel
# led = neopixel.NeoPixel(board.NEOPIXEL, 1)
led.brightness = 0.3
while True:
led[0] = (255, 0, 0)
time.sleep(0.5)
led[0] = (0, 255, 0)
time.sleep(0.5)
led[0] = (0, 0, 255)
time.sleep(0.5)
Create the LED
First, we create the LED object and attach it to the correct pin or pins. In the case of a NeoPixel, there is only one pin
necessary, and we have called it
necessary, and so we use the pin names
single onboard LED, the last thing we do is tell it that there's only
© Adafruit Industries
DotStar
(https://adafru.it/kDg)
for easier use. In the case of a DotStar, however, there are two pins
NEOPIXEL
APA102_MOSI
https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51
and
NeoPixel
and
to get it set up. Since we're using the
APA102_SCK
LED!
1
(https://adafru.it/Bej). This
Page 128 of 183
Need help?
Do you have a question about the Feather M4 Express and is the answer not in the manual?