Software

Install CircuitPython

The Adafruit Feather M4 ships with CircuitPython but lets go ahead and update it to the latest version. It's super easy with the circuitpython.org website, just click the link below to launch the page. There you can choose to install stable release or beta. 

Quick Start

  • Connect board to computer via a known good USB and double press the reset button.
  • Download the CircuitPython UF2 and upload to the FEATHERBOOT drive.
  • Open CIRCUITPY drive and upload the required libraries (listed below) and code.py

Adafruit Circuit Python Libraries

Download the CircuitPython library bundle and unzip the folder. Create a new folder in the CIRCUITPY drive and name it "lib". The following libraries are required to run the code properly. Double check to ensure all of the files and folders are inside the lib folder on the CIRCUITPY drive.

  • adafruit_bus_device (directory)
  • adafruit_lis3dh.mpy
  • neopixel.mpy
  • adafruit_rgbled.py
  • simpleio.mpy

Upload code.py

Click the link below to download the project code. Save it as code.py on your CIRCUITPY drive.

import time
import board
import adafruit_rgbled
import digitalio

POWER_PIN = board.D10

enable = digitalio.DigitalInOut(POWER_PIN)
enable.direction = digitalio.Direction.OUTPUT
enable.value = True

# Pin the Red LED is connected to
RED_LED = board.D11

# Pin the Green LED is connected to
GREEN_LED = board.D12

# Pin the Blue LED is connected to
BLUE_LED = board.D13

# Create the RGB LED object
led = adafruit_rgbled.RGBLED(RED_LED, GREEN_LED, BLUE_LED)

# Optionally, you can also create the RGB LED object with inverted PWM
# led = adafruit_rgbled.RGBLED(RED_LED, GREEN_LED, BLUE_LED, invert_pwm=True)

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

def rainbow_cycle(wait):
    for i in range(255):
        i = (i + 1) % 256
        led.color = wheel(i)
        time.sleep(wait)

while True:
    # rainbow cycle the RGB LED
    rainbow_cycle(0.1)

Troubleshooting

If it's not working, make double-sure you have all the above libraries installed in your "lib" folder. Also be sure all your wire connections are tight and the wires are connected up correctly.

More about CircuitPython can be found here!

Important Note about Power!!

Do NOT leave the battery pack plugged in to the Feather while you also have a USB cord plugged in. The Feather has onboard charging, so it will try to charge your AA batteries, which could result in battery damage and / or Feather damage. 

This guide was first published on Jun 18, 2019. It was last updated on Jun 18, 2019. This page (Software) was last updated on Oct 19, 2019.