Overview

DIY Electronics & Props

In this project we’ll show you how to build a light up prop using Adafruit’s prop-maker! This is fully 3D printed and has a collapsible blade. It’s made from segments that are tapered so it can retract. It makes a pretty cool effect when you swing it around.

DIY Electronics & 3D Printing 

All of the electronics are housed inside the 3D printed hilt. It’s also got an accelerometer for motion activated sound effects. It plays different sounds for swings and hits. They’re also randomized and feel pretty responsive to your motion. The blade is removable and the hilt makes a pretty sweet flashlight. Inside the emitter is an insanely bright 3W RGB LED.

Adafruit Feather M4 Express - Featuring ATSAMD51

PRODUCT ID: 3857
It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox,...
$22.95
IN STOCK

Adafruit Prop-Maker FeatherWing

PRODUCT ID: 3988
The Adafruit Feather series gives you lots of options for a small, portable, rechargeable microcontroller board. Perfect for fitting into your next prop build! This FeatherWing will...
$9.95
IN STOCK

3W RGB LED - Common Anode

PRODUCT ID: 2530
Better grab your sunglasses, your sunscreen, and a bucket hat because this 3W RGB LED is so bright it's like like taking a beach...
$2.95
IN STOCK

Lithium Ion Cylindrical Battery - 3.7v 2200mAh

PRODUCT ID: 1781
Need a big battery for your project? This lithium ion battery contains a 2200mAh and a protection circuit that provides over-voltage, under-voltage and over-current protection. Yet, it...
$9.95
IN STOCK

Mini Panel Mount SPDT Toggle Switch

PRODUCT ID: 3221
This or that, one or the other, perhaps or perhaps not! So hard to make decisions these days without feeling like you're just going back and forth constantly. Deciding whether or...
$0.95
IN STOCK

Mini Oval Speaker - 8 Ohm 1 Watt

PRODUCT ID: 3923
Hear the good news! This wee speaker is a great addition to any audio project where you need 8 ohm impedance and 1W or less of power. We particularly like...
$1.95
IN STOCK

Circuit Diagram

Circuit Diagram

This provides a visual reference for wiring of the components. They aren't true to scale, just meant to be used as reference. This diagrams was created using Fritzing software.

Adafruit Library for Fritzing

Use our Fritzing parts library to create circuit diagrams for your projects. Download the library or just grab the individual parts. Get library and parts from GitHub Adafruit Fritzing Parts.

Wired Connections

The Prop-Maker FeatherWing is fitted on top of Adafruit Feather M4 Express via female/male headers. The speaker is connected via a molex pico blade connector.

Powering

The Adafruit Feather M4 Express can be powered via USB or JST using a 3.7v lipo battery. In this project, a 2200mAh lipo battery is used. The lipo battery is rechargeable via the USB port on the Adafruit Feather. The switch is wired to the enable and ground pins on the Prop-Maker FeatherWing. 

3W RGB LED

  • red pin (R-) to red pin on Prop-Maker FeatherWing
  • green pin (G-) to green pin on Prop-Maker FeatherWing
  • blue pin (B-) to blue pin on Prop-Maker FeatherWing
  • voltage pin (V+) to V+ pin on Prop-Maker FeatherWing

Speaker

  • Voltage and ground to Prop-Maker speaker port

Toggle Switch

  • Middle pin to enable pin on Prop-Maker
  • Far left or right pin to ground on Prop-Maker
Note the RGB LED can get H-O-T HOT! Be careful to not touch it or allow flammable materials around it if it is very hot. This is how these parts are designed, to be so bright, and it is not a part design issue.

3D Printing

3D Printed Parts

Parts are designed to be 3D printed with FDM based machines. STL files are oriented to print "as is". Machines with dual extrusion or single extrusion setups are listed below with parts name and description. Parts require tight tolerances that might need adjusting slice setting. Reference the suggested settings below.

CURA Slicing

Parts were sliced using Ultimaker's CURA software and tested with an Ultimaker 3 and Flashforge Inventor II. The kit requires a minimum build volume of 50mm x 50mm x 190mm. No support material is necessary for any of the parts. Double check parts are positioned in the center of the build plate before printing. 

Settings

Use these settings as reference. Values listed were used in Ultimaker's CURA slicing software.

  • 0.2mm Layer Height / 0.4mm nozzle
  • 0.38mm Line Width (inner & outer widths)
  • 40mm/s printing speed
  • 20% infill
  • Supports: No

Parts List

  • emitter-cover.stl
  • emitter-cap.stl
  • lens-cover.stl
  • lens-holder.stl
  • led-holder.stl
  • pcb-holder.stl
  • pcb-holder-tab.stl
  • bat-holder.stl
  • body.stl
  • speaker-clip.stl
  • pommel.stl

Designing Things

The fusion 360 source file is included and features original sketches and feature timeline along with easily editable user parameters. The parts can further be separated into small pieces for fitting on printers with smaller build volumes. Note: STEP file is included for other 3D surface modeling programs such as Onshape, Solidworks and Rhino.

Layer by Layer

Interested in CAD tutorials? Check out my playlist on YouTube – There's over 100 of them! My personal favorite is the snap fit tutorial for cases and enclosures. 

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

Upload code.py

Click the link below to download the project  zip – This contains the code, audio and 3D files. Upload the code.py file to the CIRCUITPY drive.

Create a new folder on the CIRCUITPY drive and name it "sounds". Upload the audio files to that folder. The code will run properly when all of the files have been uploaded.

"""
Prop-Maker based Light Up Prop.
Adafruit invests time and resources providing this open source code.
Please support Adafruit and open source hardware by purchasing
products from Adafruit!
Written by Kattni Rembor for Adafruit Industries
Copyright (c) 2019 Adafruit Industries
Licensed under the MIT license.
All text above must be included in any redistribution.
"""
import time
import random
import digitalio
import audioio
import busio
import board
import adafruit_rgbled
import adafruit_lis3dh

# CUSTOMISE COLORS HERE:
MAIN_COLOR = (255, 0, 0)  # Default is red
HIT_COLOR = (255, 255, 255)  # Default is white

# CUSTOMISE SENSITIVITY HERE: smaller numbers = more sensitive to motion
HIT_THRESHOLD = 650
SWING_THRESHOLD = 125

# Set to the length in seconds of the "on.wav" file
POWER_ON_SOUND_DURATION = 1.5

POWER_PIN = board.D10

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

# 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)

audio = audioio.AudioOut(board.A0)  # Speaker

# Set up accelerometer on I2C bus, 4G range:
i2c = busio.I2C(board.SCL, board.SDA)
accel = adafruit_lis3dh.LIS3DH_I2C(i2c)
accel.range = adafruit_lis3dh.RANGE_4_G

COLOR_HIT = HIT_COLOR  # "hit" color is HIT_COLOR set above
COLOR_SWING = MAIN_COLOR  # "swing" color is MAIN_COLOR set above


def play_wav(name, loop=False):
    """
    Play a WAV file in the 'sounds' directory.
    :param name: partial file name string, complete name will be built around
                 this, e.g. passing 'foo' will play file 'sounds/foo.wav'.
    :param loop: if True, sound will repeat indefinitely (until interrupted
                 by another sound).
    """
    print("playing", name)
    try:
        wave_file = open('sounds/' + name + '.wav', 'rb')
        wave = audioio.WaveFile(wave_file)
        audio.play(wave, loop=loop)
    except:  # pylint: disable=bare-except
        return


# List of swing wav files without the .wav in the name for use with play_wav()
swing_sounds = [
    'swing1',
    'swing2',
    'swing3',
    'swing4',
    'swing5',
    'swing6',
    'swing7',
    'swing8',
]

# List of hit wav files without the .wav in the name for use with play_wav()
hit_sounds = [
    'hit1',
    'hit2',
    'hit3',
    'hit4',
    'hit5',
    'hit6',
    'hit7',
    'hit8',
]

mode = 0  # Initial mode = OFF

# Main loop
while True:
    if mode == 0:  # If currently off...
        enable.value = True
        play_wav('on')  # Power up!
        led.color = MAIN_COLOR
        time.sleep(POWER_ON_SOUND_DURATION)
        play_wav('idle', loop=True)  # Play idle sound now
        mode = 1  # Idle mode

    elif mode >= 1:  # If not OFF mode...
        x, y, z = accel.acceleration  # Read accelerometer
        accel_total = x * x + z * z
        # (Y axis isn't needed, due to the orientation that the Prop-Maker
        # Wing is mounted.  Also, square root isn't needed, since we're
        # comparing thresholds...use squared values instead.)
        if accel_total > HIT_THRESHOLD:  # Large acceleration = HIT
            play_wav(random.choice(hit_sounds))  # Start playing 'hit' sound
            COLOR_ACTIVE = COLOR_HIT  # Set color to fade from
            mode = 3  # HIT mode
        elif mode == 1 and accel_total > SWING_THRESHOLD:  # Mild = SWING
            play_wav(random.choice(swing_sounds))  # Randomly choose from available swing sounds
            led.color = MAIN_COLOR  # Set color to main color
            mode = 2  # SWING mode
        elif mode == 1:
            # Idle color
            led.color = MAIN_COLOR
        elif mode > 1:  # If in SWING or HIT mode...
            if audio.playing:  # And sound currently playing...
                if mode == 2:  # If SWING,
                    led.color = MAIN_COLOR
                else:
                    led.color = HIT_COLOR  # Set color to hit color
            else:  # No sound now, but still SWING or HIT modes
                play_wav('idle', loop=True)  # Resume idle sound
                mode = 1  # Return to idle mode

Settings and Customization

If your are building the project as is, you shouldn't have to edit any of the values in the code. But, if you have a different setup, you'll want to read through the comments and make your desired changes.

  • Use the MAIN_COLOR and ALT_COLOR variables to change the main color of the RGB LED.
  • Accelerometer sensitivity can be adjusted in the HIT_THRESHOLD and SWING_THRESHOLD.
  • Audio is set to output via pin A0 (That's the analog pin #0 on the Feather M4 express).

Audio Files

The sounds used in this project are from the JKDF Soundfont pack, available to download here. The pack contains various sounds that are already in the supported audio format. Select the files you like and name them accordingly. 

Adafruit CircuitPython supports 16-bit, Mono, 22.050kHz .wav audio format. See this guide to help format any audio files you might want to use in this project besides the files provided.

In the main loop, the swing and hit modes randomly choose from a list of sounds. For example, swing1.wav, swing2.wav, swing3, etc. This makes the motion effects feel much more varied and sounds less repetitive.

  • Power on – on.wav
  • Idle looping noise – idle.wav
  • Swing whoosh – swing.wav
  • Crash strike – hit.wav

Wiring

The wiring portion of this guide is documented as an instruction course video. Watch and follow along to proceed with the build.

The voiceover transcript is available below.

We’ll start by assembling the headers on the Adafruit Feather and Prop-Maker

Insert the strip of male headers into the row of pins on the outer edge of the PCB.

I like to use a breadboard to help keep the headers straight. Just be sure to line up them up properly.

With the headers now place we can solder all of the pins. If you’re new to this, be sure to check out Adafruit’s guide to excellent soldering.

Once all of the pins have been soldered, you can remove the PCB and double check to make sure they have enough solder.

Next we can install the female header on top of the Feather Express.

To help with installing the headers, we’ll use the FeatherWing– Just snap it top and this will help keep the female headers in place while we solder.

I like to use a PCB vise – This helps keep it in place so it doesn’t move around. The stick vise is nice because it lets you clamp it down.

With the PCB secured we can add solder to install the female headers.

When soldering, you want to heat up both the pad and the lead and then add solder. Once applied, remove the solder but keep the iron still on the joint a bit and then remove the iron.

Once we’re done soldering, remove the PCB and inspect the joints – you’ll want to make sure there’s enough solder and no cold joints.

We’ll use a 4-pin JST cable to connect the LED to the PropMaker.

Since it’s an RGB leds it’ll need four wired connections.

Third helping hands keep the PCB in place while we solder up the wires.

For more grip we put pieces of heat shrink tubing on the little grabbers.

Once it’s in a good spot we can tin the pads by adding a bit of solder.

You’ll need to be quick about it because the aluminum backing dissipates heat making it a bit tricky.

Next we can plan out the wired connections before soldering to the pads.

Here I’m connecting the white wire to the blue pad. Green wire to the green pad. Red wire to the red pad. Then connecting the black wire to the common anode. Be sure to check the joints. These need to be pretty solid. I did this a couple of times before getting good connections.

We’ll use a 2-pin JST cable to connect the toggle switch to the PropMaker.

Use wire cutters and shorten the cable. We’ll need these two cables for their JST connectors.

We’ll solder one of these JST cables to the toggle switch.

Using wire strippers, remove a bit of insulation from the wires.

Tin the exposed wire by adding a bit of solder. This will prevent the strands of wires from fraying.

Now we can connect the cable to the leads on the toggle switch.

Helping hands will keep the switch sturdy while soldering the wires.

Add a bit of solder to the leads first then we can get the wire connected.

Make sure to connect the middle lead and then one of the other leads on either side.

Double check your wiring and make sure the connections are solid.

Next we’ll connect the other JST cable to the Propmaker FeatherWing.

I’ll start by securing the PCB to the stickvise with the bottom side facing up.

Add a bit of solder to tin the enable and ground pins.

Now we can connect the two wires from the cable. Polarity doesn’t matter as long as both pins are wired.

With it connected to the enable and ground pins, the toggle switch can cut the power.

This JST cable is positioned to go in between the Feather and FeatherWing.

Next we’ll connect a 4-pin JST cable to the PropMaker. This will connect to the 3W RGB LED.

The connectors snap together and make the assembly much easier.

I’ll fit the PCB back onto the stickvise bottom side up.

Then tin the RGB LED pads on the Propmaker.

We’ll need to match the connections with the wiring on the 3W RGB LED.

Double check the wired connections and make sure the joints are solid.

Now we can snap the PropMaker on top of the Feather.

Go ahead and plug in the LED and toggle switch to the Propmaker using the JST cables.

This mini oval speaker connects directly to the speaker port.

We can also plug in the lipo battery to the Feather.

Once the code is uploaded, we can test out the circuit and make sure everything works.

Assembly

The assembly portion of this guide is documented as an instructional video. Watch and follow along to proceed with the build.

The voiceover transcript is available below.

We’ll start the assembly by building the emitter.

Join the emitter cap to the LED plate and line up the mount holes. Then insert the brass standoffs into these holes. Now we can insert two screws into the remaining holes.

Tightly fasten lock nuts onto the thread of the screws to secure the parts.

Next we’ll set the RGB LED and battery.

Insert the JST cable from the LED and put it through the hole in the middle of the emitter.

Grab the battery holder and pass it through the JST cable. Place the wires on one of the groves.

Then, fit the battery through the holder. Make sure the cable is facing outside.

Now we can begin to fit the battery through the top of the hilt.

With the cable going in first, insert the battery holder and fit it through the hilt.

You can then start to screw the emitter cap onto the hilt. Be sure to pull the battery cable out the other end.

Next we can install the mini toggle switch. Grab the cables to make room and insert the switch into the opening on the hilt.

Fit the actuator through the mounting hole so it sticks out the other side. Now we can add the washer and hex nut over the stem of the switch.

Grab the LED and position it so the mounting holes line up with the brass standoffs.

Begin to insert and fasten machine screws to secure the PCB. Use a screwdriver to tightly fasten the screws.

Next we’ll setup the feather and propmaker with the PCB holders.

This will make it easier to fit the PCBs through the hilt.

These fit over the mounting holes and clip onto the edges.

You’ll need to install these on both ends of the PCB.

Double check and make sure the tabs are lined up with the mounting holes.

You can go ahead and secure them in place using M2.5 nylon screws.

The groves on the sides will allow this slide through the rails inside the hilt.

Next we’ll install the speaker.

Start by threading the cable through the opening on the side of the hilt.

Pull the cable through the bottom and keep the speaker outside the hilt.

Now we can start to install the PCB holders through the hilt.

Line up the groves with the rails and push the PCBs through the bottom.

Insert it about half way through and get ready to plug in the speaker and battery.

Grab the speaker cable and plug it into the speaker port.

After that we gather up the remaining JST cable and plug them up. Here we’re making the connections for the LED and switch.

With those now plugged in, we can go ahead and connect the battery to the feather.

The PCBs can now be pushed up inside the body of the hilt.

And we should still have access to the microUSB port.

You can then grab the pommel and screw it onto the bottom of the hilt.

One of the last parts to install is the speaker

Start by peeling off the protective backing and then go ahead and stick it into the speaker holder. You’ll need to press fit it into the holder.

Now we can install the speaker holder onto the hilt.

Groves on the inside of the holder wrap around the rail along the outside of hilt.

You can pull apart the clip to fit it over the hilt.

Next we can set up the lens holder and blade.

Place the focusing lens over the center of the holder. Then grab the lens cover and line up the parts so they press fit. The lens cover twist locks into place.

The shield covering is then installed to the outside of the lens holder.

With the lens holder now assembled, we can screw it on top of the emitter. These parts have threads so they’ll need to be tightly fastened.

With the emitter now put together, you can install the blade. This can be press fitted over the lens holder. The tolerances are snug but it’s still removable. For a more permanent hold, you can use super glue or other adhesives.

Go ahead and turn it on – Check out the light diffusion in the blade. Different types of filaments will affect the light diffusion. The focusing lens contains the light and helps prevent light leaking.

Note the RGB LED can get H-O-T HOT! Be careful to not touch it or allow flammable materials around it if it is very hot. This is how these parts are designed, to be so bright, and it is not a part design issue.
This guide was first published on Jun 19, 2019. It was last updated on Jun 19, 2019.