EasyManua.ls Logo

Adafruit Feather M4 Express - Page 129

Adafruit Feather M4 Express
178 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
If the power to the NeoPixels is greater than 5.5V you may have some difficulty driving some strips, in which case you
may need to lower the voltage to 4.5-5V or use a level shifter.
The Code
This example includes multiple visual effects. Copy and paste the code into code.py using your favorite editor, and
save the file.
Do not use the VIN pin directly on Metro M0 Express or Metro M4 Express! The voltage can reach 9V and this
can destroy your NeoPixels!
Note that the wire ordering on your NeoPixel strip or shape may not exactly match the diagram above. Check
the markings to verify which pin is DIN, 5V and GND
# CircuitPython demo - NeoPixel
import time
import board
import neopixel
pixel_pin = board.A1
num_pixels = 8
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False)
def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if pos < 0 or pos > 255:
return (0, 0, 0)
if pos < 85:
return (255 - pos * 3, pos * 3, 0)
if pos < 170:
pos -= 85
return (0, 255 - pos * 3, pos * 3)
pos -= 170
return (pos * 3, 0, 255 - pos * 3)
def color_chase(color, wait):
for i in range(num_pixels):
pixels[i] = color
© Adafruit Industries https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51 Page 134 of 183

Table of Contents

Related product manuals