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:
DotStar
(https://adafru.it/kDg)
and
NeoPixel
(https://adafru.it/Bej)
. This
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.
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
NEOPIXEL
for easier use. In the case of a DotStar, however, there are two pins
necessary, and so we use the pin names
APA102_MOSI
and
APA102_SCK
to get it set up. Since we're using the
single onboard LED, the last thing we do is tell it that there's only
1
LED!
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)
© Adafruit Industries
https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51
Page 128 of 183
Содержание Feather M4 Express
Страница 1: ...Adafruit Feather M4 Express Created by lady ada Last updated on 2019 03 04 10 41 14 PM UTC...
Страница 5: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 10 of 183...
Страница 58: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 63 of 183...
Страница 164: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 169 of 183...
Страница 168: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 173 of 183...