The Prop-Maker FeatherWing is loaded with features to help with your next build. Here, we'll go over how to use each of the features in CircuitPython. We'll provide a simple example that you can expand on to include it in your project. Save the code to code.py on your board to run the example!

NeoPixels

CircuitPython makes it super simple to use the NeoPIxels connected via the snap-in NeoPixel connector on the Prop-Maker FeatherWing.

This example lights up a 30-pixel NeoPixel strip in a rainbow. Change NUM_PIXELS to match the number of NeoPixels you've connected to your FeatherWing.

# SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""Simple rainbow example for 30-pixel NeoPixel strip"""
import digitalio
import board
from rainbowio import colorwheel
import neopixel

NUM_PIXELS = 30  # NeoPixel strip length (in pixels)

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

strip = neopixel.NeoPixel(board.D5, NUM_PIXELS, brightness=1)

while True:
    for i in range(255):
        strip.fill((colorwheel(i)))

For more information, check out the Adafruit NeoPixel Überguide!

Audio

The speaker connector on the Prop-Maker FeatherWing makes it easy to attach a speaker to playback audio for your project.

This example only works on Feathers that have analog audio out, such as the Feather M0 Express or Feather M4.

This example plays once through a wave file called "StreetChicken.wav". Click the button below to download the file and copy it to your board. You can also add any compatible wave file and change the code to match the name of your file.

# SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""Simple example to play a wave file"""
# This example only works on Feathers that have analog audio out!
import digitalio
import board
import audioio
import audiocore

WAV_FILE_NAME = "StreetChicken.wav"  # Change to the name of your wav file!

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

with audioio.AudioOut(board.A0) as audio:  # Speaker connector
    wave_file = open(WAV_FILE_NAME, "rb")
    wave = audiocore.WaveFile(wave_file)

    audio.play(wave)
    while audio.playing:
        pass

For more information, check out Audio Out in the CircuitPython Essentials Guide!

Accelerometer

You can easily access the acceleration data from the LIS3DH accelerometer in the center of the Prop-Maker FeatherWing using CircuitPython.

This example prints the acceleration data to the serial console. Move the board around to see the values change.

# SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""Simple example to print acceleration data to console"""
import time
import digitalio
import board
import busio
import adafruit_lis3dh

# Set up accelerometer on I2C bus, 4G range:
i2c = busio.I2C(board.SCL, board.SDA)
int1 = digitalio.DigitalInOut(board.D6)
accel = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)
accel.range = adafruit_lis3dh.RANGE_4_G
accel.set_tap(1, 100)

while True:
    x, y, z = accel.acceleration
    print(x, y, z)
    time.sleep(0.1)
    if accel.tapped:
        print("Tapped!")

For more information, check out the LIS3DH guide!

3 Watt LED

You can control the colors and brightness of a 3 Watt RGB LED using CircuitPython.

This example uses PWM to light up the LED with a rainbow swirl.

# SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""Simple rainbow swirl example for 3W LED"""
import pwmio
import board
from rainbowio import colorwheel
import digitalio

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

red = pwmio.PWMOut(board.D11, duty_cycle=0, frequency=20000)
green = pwmio.PWMOut(board.D12, duty_cycle=0, frequency=20000)
blue = pwmio.PWMOut(board.D13, duty_cycle=0, frequency=20000)

while True:
    for i in range(255):
        r, g, b = colorwheel(i)
        red.duty_cycle = int(r * 65536 / 256)
        green.duty_cycle = int(g * 65536 / 256)
        blue.duty_cycle = int(b * 65536 / 256)

For more information, check out PWM in the CircuitPython Essentials Guide!

Switch

You can easily use the mechanical switch on the Switch pin with CircuitPython.

The following example prints to the serial console when the switch is closed.

# SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""Simple example to print when switch is pressed"""
import time
import digitalio
import board

switch = digitalio.DigitalInOut(board.D9)
switch.switch_to_input(pull=digitalio.Pull.UP)

while True:
    if not switch.value:
        print("Switch pressed!")
    time.sleep(0.1)

This guide was first published on Jan 23, 2019. It was last updated on Jan 23, 2019.

This page (CircuitPython Code) was last updated on Mar 23, 2023.

Text editor powered by tinymce.