Install CircuitPython

Before you start you'll need to install CircuitPython onto your Feather. We have full introduction guide that will get your board loaded up

Download Adafruit CircuitPython NeoPixel Library

Now we need to get the Circuit Python NeoPixel library.

Follow this link to learn how to install neopixel.mpy into your Feather's library folder

Upload The Code

Copy and paste the code below into a new text document (we recommend using Mu). Save the file and name it as main.py

Once the files has been uploaded to the drive, the Feather will automatically reboot and run the code. No upload button (say whaaat?!).

Text Document Formatting

If you're not using Mu, watch out for text formatting! When making your text document, you need to ensure the file is set as Plain Text. Most common text editing applications, like TextEdit for MacOS will save text documents as .RTF (rich text format) by default. You can quickly change an RTF text document to plain text by using selecting "Make Plain Text" under the Format menu. You can also change the format in the applications "Preferences" menu.

Line Spaces and Invisible Characters

If you are still finding your code isn't quite working and running. You can try copying the code into a different text editing software, such as Microsoft Word, save it out as a .txt format with line spacing and then convert it to the .py file extension. Sometimes text editors will add invisible characters like line breaks and tabbed spaces.

Color Fill

The code below will "fill in" all of the NeoPixel LEDs with a single color. This is great if you just want a simple always on LEDs with no animation. If you want to change the color, type in different numbers in the line with strip.fill([0, 0, 0]) to whatever RGB (red, green blue) color values you'd like. For example, an orange color would be 255, 120, 0.

from digitalio import *
from board import *
import neopixel
import time

pixpin = D6
numpix = 8

led = DigitalInOut(D13)
led.direction = Direction.OUTPUT

strip = neopixel.NeoPixel(pixpin, numpix, brightness=0.5)

while True:
    strip.fill([50, 0, 100])
    strip.write()

Rainbow Animation

The code below will make the NeoPixel LEDs fade between different colors in the RGB color spectrum.

from digitalio import *
from board import *
import neopixel
import time

pixpin = D6
numpix = 8

led = DigitalInOut(D13)
led.direction = Direction.OUTPUT

strip = neopixel.NeoPixel(pixpin, numpix, brightness=.5)


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):
        return [0, 0, 0]
    if (pos > 255):
        return [0, 0, 0]
    if (pos < 85):
        return [int(pos * 3), int(255 - (pos*3)), 0]
    elif (pos < 170):
        pos -= 85
        return [int(255 - pos*3), 0, int(pos*3)]
    else:
        pos -= 170
        return [0, int(pos*3), int(255 - pos*3)]

def rainbow_cycle(wait):
    for j in range(255):
        for i in range(len(strip)):
            idx = int ((i * 256 / len(strip)) + j)
            strip[i] = wheel(idx & 255)
        strip.write()
        time.sleep(wait)

def rainbow(wait):
    for j in range(255):
        for i in range(len(strip)):
            idx = int (i+j)
            strip[i] = wheel(idx & 255)
	strip.write()

while True:
    rainbow(0.001)

This guide was first published on Aug 30, 2017. It was last updated on Aug 30, 2017.

This page (Software Setup) was last updated on Aug 29, 2017.

Text editor powered by tinymce.