Once you've finished setting up your Feather RP2040 with CircuitPython, you can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the Download Project Bundle button in the window below. It will download as a zipped folder.

# SPDX-FileCopyrightText: 2022 Noe Ruiz for Adafruit Industries
# SPDX-License-Identifier: MIT
# Magic Band Reader with Wiz Kit RFID
import random
import board
import digitalio
import audiobusio
from audiocore import WaveFile
import neopixel
from adafruit_led_animation.animation.chase import Chase
from adafruit_led_animation.animation.solid import Solid
from adafruit_led_animation.color import (
    GREEN,
    BLACK,
)

# Setup button switch
button = digitalio.DigitalInOut(board.A1)
button.switch_to_input(pull=digitalio.Pull.DOWN)

# LRC is word_select, BCLK is bit_clock, DIN is data_pin.
# Feather RP2040
audio = audiobusio.I2SOut(bit_clock=board.D24, word_select=board.D25, data=board.A3)

# Make the neopixel object
pixels = neopixel.NeoPixel(board.D6, 24, brightness=.4)

# Setup the LED animations
chase = Chase(pixels, speed=0.02, color=GREEN, size=4, spacing=24)
solid = Solid(pixels, color=BLACK)

#Fuction for playing audio
def play_wav(name):
    print("playing", name)
    wave_file = open('sounds/' + name + '.wav', 'rb')
    wave = WaveFile(wave_file)
    audio.play(wave)

#List of audio files
sounds = [
    'chime',
    'excellent',
    'foolish',
    'hello',
    'operational',
    'startours'
]
while True:
    print("Waiting for button press to continue!")
    while not button.value:
        solid.animate()
    play_wav(random.choice(sounds))
    while audio.playing:
        chase.animate()
    print("Done!")

Upload the Code and Libraries to the Feather RP2040

After downloading the Project Bundle, plug your Feather into the computer's USB port with a known good USB data+power cable. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called CIRCUITPY. Unzip the folder and copy the following items to the Feather RP20402's CIRCUITPY drive. 

  • code.py
  • lib directory
  • wav directory

Your Feather RP2040 CIRCUITPY drive should look like this after copying the lib folder, wav folder and the code.py file.

This guide was first published on Nov 01, 2022. It was last updated on Nov 01, 2022.

This page (Coding the Magic Band Reader) was last updated on Mar 20, 2023.

Text editor powered by tinymce.