Overview

Build a sci-fi inspired bike light using Adafruit Feather and NeoPixels. Use an RGB LED Button to cycle through different colors and animations. The button will actually match the colors of the NeoPixels!

3D Printed Headlight

This is a 3D printed a headlight for my bike. I designed a mounting plate to house a 24x NeoPixel ring and 7x NeoPixel Jewel. The headlight fixture was inspired by rocket boosters and jet engines. I had the idea of an illuminated edge band that wraps around a cylinder with an illuminated inner core. By combining black PLA and translucent PLA, you can mask out certain geometry while illuminating other elements. I've been meaning to design specifically for dual extrusion such as the Ultimaker 3 and this is what I came up with. 

Adafruit's Feather Platform

I wanted to use the Adafruit Feather platform because it's fully featured and expandable via the FeatherWing add-ons. With on-board USB charging, it makes it easy recharge the battery.    

Circuit Python Powered

An RGB LED Button is used to cycle through different colors and animations on the NeoPixels. The code is written in Adafruit's Circuit Python. When you connect the Adafruit Feather to your computer via USB cable, it shows up like a flash drive. The code and libraries are accessible anytime, on any computer (even some mobile devices!). The code live on the drive, so you don't need an IDE to change or upload code. This allows for quick code changes and great for accessibility.

Prerequisite Guides

If you're new to Adafruit Feather M4 Express, CircuitPython or soldering, take a moment to walk through the following guides to get you started.

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. Files are hosted on our github repo linked below.

Wired Connections

24 NeoPixel Ring

  • Pin 6 from Feather to Data In on 24x NeoPixel Ring
  • GND from Feather to GND on 24x NeoPixel Ring
  • 3V from Feather to PWR on 24x NeoPixel Ring

7 NeoPixel Jewel

  • PWR from NeoPixel Ring to PWR on NeoPixel Jewel
  • GND from NeoPixel Ring to GND on NeoPixel Jewel
  • Data Out from NeoPixel Ring to Data In on NeoPixel Jewel

RGB LED Button

  • Pin 9 from Feather to Red Cathode on RGB LED
  • Pin 10 from Feather to Green Cathode on RGB LED
  • Pin 11 from Feather to Blue Cathode on RGB LED
  • 3V from Feather to Common Anode on RGB LED
  • GND from Feather to Button
  • Pin 12 from Feather to Button

Toggle Switch

  • GND from Feather to Toggle Switch
  • EN from Feather to Toggle Switch

Powering

The Adafruit Feather M4 Express can be powered via USB or JST using a 3.7v lipo battery. In this project, a 4400mAh lipo battery is used. The lipo battery is rechargeable via the USB port on the Adafruit Feather.

Software

Setup Adafruit Feather M4 for CircuitPython

Your Feather M4 should already come with CircuitPython but maybe there's a new version, or you overwrote your board with Arduino code! In that case, see the below for how to reinstall or update CircuitPython. Otherwise you can skip this and proceed with the build.

CircuitPython Libraries

Install the Adafruit NeoPixel library for Circuit Python by downloading the latest bundle. Unzip the file and locate the needed libraries. Drop the libraries into a folder named "lib" on the CIRCUITPY drive.

For non-express boards like the Trinket M0 or Gemma M0, you'll need to manually install the necessary libraries from the bundle.

Required CircuitPython Libraries:

  • neopixel
  • adafruit_fancyled
  • simpleio

Before continuing make sure your board's lib folder or root filesystem has the neopixel.mpy file was copied over.

Upload The Code

Copy and paste the code below into a new text document (we recommend using Mu as your editor, which is designed for CircuitPython.). Save the file and name it as main.py

Once the files has been uploaded to the drive, the board will automatically reboot and run the code.

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.

Clips for Bike Frame

The headlight and box enclosure are designed to clamp onto the bike framing. There's a lot of different types of bikes, each with different sizes of framing. Take a moment to measure your bikes framing to ensure the clips will fit.

  • Box clips: 38mm (1.5 inches) diameter
  • Headlight clips: 23mm (0.9inches) diameter.

Dry Fit Parts

I suggest testing out the parts before installing the electronics. Print out the clips and try fitting them onto your bike frame. Fit the bhl-box-clip.stl parts onto the railing of the box enclosure – If the tolerances are too tight, use a filing tool to loosen up the edges. Fit the bhl-cover-jst.stl and bhl-cover-usb.stl parts onto the box enclosure.

Tap Mounting Holes

I used a set of screw taps to create threads in the various mounting holes. This greatly improves fastening screws. of the A mix of metric sizes are used here. M2.5 tap for the Feather mounting plate. M3 tap for the majority of the mounting holes.

Slice Settings

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

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

Dual Extruded Headlight

The headlight was designed to be dual extruded using black and translucent PLA filament. When backlit, any geometry printed in translucent filament will illuminate and diffuse the lighting from the NeoPixels. If your 3D printer is not equipped with a dual extruder, you can 3D print the part in translucent PLA and mask certain areas with black acrylic paint.

Dual Extruded Box Enclosure

One side of the box features "grill" details that are printed in a silver colored filament. This is purely for aesthetics and does serve any functionality (other than testing your dual extrusion setup!). You have the option to print a "single" extrusion version.

bhl-plate.stl

Mounting plate houses NeoPixel Ring and NeoPixel Jewel.

bhl-plate-clip.stl

Clips attach to mounting plate and bike framing.

bhl-headlight-a.stl

Headlight diffuser – Ideally print in a dark colored filament.

bhl-headlight-b.stl

Headlight diffuser – Ideally printed in translucent colored filament.

bhl-box-a.stl

Enclosure houses electronics.

bhl-box-b.stl

Grill details on the side of the box enclosure.

bhl-box-single.stl

Box enclosure for single extrusion.

bhl-headlight-single.stl

Headlight diffuser setup for single extrusion.

Glitter Infused Filament from Fillamentum

The material used to print the some of the parts in this project are from Fillamentum. From the PLA Extrafill line of filaments, Vertigo Galaxy PLA and  Rapunzel Silver PLA was used. Translucent PLA material was used to print the bhl-headlight-b.stl part.

Button Wiring

Button Wiring

The RGB LED button needs six wired connections. To make the assembly more efficient, I used JST-PH cables with male and female connectors. This allows for quick connections. A 4-pin and 2-pin JST cable set can be used to connect the button the Adafruit Feather.

Suggested Wire Length: 70mm (2.8in)

Solder Button Wires

The connections are labeled on the bottom of the button housing. Reference the labels and sort out which wire will be soldered to the pins. The polarity from the two JST-PH cables needs to match exactly. To make soldering easier, I tinned each of the pins with a bit of solder. A Panavise can secure the button in place while soldering.

Switch Wiring

Switch Wires

The on/off toggle switch needs two wired connections. Male and Female 2-pin JST-PH cables are used here to make good use of quick connects. These cables are 70mm (2.8in) in length.

Solder Switch Wires

A set of third helping hands can assist in holding the switch in place while soldering the wires to the pins. The switch has three pins but we only need to use two of them. Solder wires to the middle pin and either the far left or right, as shown the photo. 

Feather Wiring

Feather Wired Connections

With the button and switch wired with JST-PH cables, solder the corresponding wires to the Adafruit Feather. Take a moment to reference the wired connections and sort out the polarity and ensure they're matching.

Feather RGB LED Wiring

Solder the 4-pin JST-PH cable to the pins on the Feather. Make sure each connection matches the corresponding polarity.

  • D9 – Red LED
  • D10 – Green LED
  • D11 – Blue LED 
  • 3V – Common Anode

Feather Button

Solder the 2-pin JST-PH cable from the button to the Feather. Polarity from the push button doesn't matter here so the connections do not have to match the corresponding cable.

  • D12 – Button
  • GND – Button 

Feather Switch

Solder the 2-pin JST-PH cable from the toggle switch to the Feather. Polarity doesn't necessarily matter here as long as the correct pins are wired. 

  • EN – Switch
  • GND – Switch

NeoPixel Wiring

NeoPixel Connections

The 24 NeoPixel ring and 7 NeoPixel jewel will need a total of six connections. The NeoPixel ring and jewel will share 5V and GND connections. The Data-Out from the NeoPixel ring will need to connect to the Data-In of the NeoPixel Jewel. To connect the NeoPixel ring to the NeoPixel jewel, use three separate wires (70mm/2.8inches in length). A 3-pin JST-PH cable will be used to connect the NeoPixel ring to the Adafruit Feather.

Suggested Length for 3-Pin JST-PH Cables: 130mm (5in)

Soldering NeoPixel Ring

The 3D printed mounting plate (bhl-plate.stl) for the 24 NeoPixel ring has a series of holes that exactly match the pinouts on the PCB.  Take a moment to line up the pins with those holes. The voltage, ground and data pins are labeled on the PCB. Insert wires from the 3-pin JST cable through the holes of the mounting plate. Use the holes that correspond with the 5V, GND and Data-In pins on the 24 NeoPixel ring. Pull the wires through the plate to gain enough length for soldering. The wires will need to be soldered to the bottom side of the PCB. A set of third helping hands can secure the ring in place while soldering. It's a bit tricky to solder the wires with the mounting plate attached so take precautions not to touch the plastic with the soldering iron.

leds_neopixel-wire-part.jpg

leds_neopixel-wire-part-2.jpg

leds_neopixel-wiring.jpg

Take a moment to reference how the connections are made. Check to ensure the wires are being inserted through the correct side of the PCB and mounting plate.

NeoPixel Jewel Wires

The three separate wires will need to be soldered to the voltage, ground and data pins on the NeoPixel jewel. Colored wires help tell the connections apart. Use the labels on the PCB to reference pinouts. Solder the wires to the  5V, GND and Data Input pins. Note, the wires are soldered through the bottom side of the PCB.

Install NeoPixel Jewel

Insert the wires from the jewel through the center of the mounting plate. The center features holes that match exactly with the pinouts on the neopixel jewel. Line them up so they match. Press the PCB into the center so it's flush. Pull the wires all the way through the back of the mounting plate.

leds_jewel-wiring-2.jpg

leds_jewel-install.jpg

leds_jewel-install-wire.jpg

Solder NeoPixel Jewel

Grab the three wires from the jewel and thread them through the holes with corresponding pins. The 24 NeoPixel ring has spare voltage and ground pins that can be used. The Data In wire from the neopixel jewel needs to go to the Data Out pin on the neopixel ring.

leds_jewel-install-wire-2.jpg

leds_jewel-ring-wiring.jpg

leds_jewel-ring-wired.jpg

Connecting NeoPixel Ring to NeoPixel Jewel

Ensure the connections from the neopixel jewel are going to the correct pins on neopixel ring. There should be enough wire length to reach the pins on the PCB. A set of third helping is essential in assisting with soldering. Otherwise, it's a bit tricky to keep the PCB in place. Be careful not to touch the mounting plate with the soldering iron.

Wired NeoPixels

The wiring on the neopixels were soldered through the back in order to keep the wires away from the light source. The front facing side of the neopixels should be free from any wires. This is a bit tricky to wire, but with patience and handy tools, it can be done. If you can't get your fingers in the right place, I found a set of tweezers to be really useful. 

Wire Check

Take a moment to reference the wired connections. The corresponding 3-pin JST cable needs to have matching polarity with the Adafruit Feather. 

Wire Feather

Solder the corresponding 3-pin JST-PH cable to the Adafruit Feather. The polarity really matters here, so take a moment to reference the wiring and ensure the connections match.

  • D6 from Feather to Data-In on NeoPixels
  • GND from Feather to GND on NeoPixels
  • 3V from Feather to PWR on NeoPixels

Test NeoPixels

Before proceeding with the assembly, check the NeoPixels are wired correctly. I used a neopixel example code in circuit python to test out the NeoPixels. Be sure to update the code with the correct number of pixels and pin. Upload the code to the board if you haven't done so already. Plug in the battery to the Adafruit Feather to it test out.

Headlight Assembly

Install Headlight Diffuser

Grab the headlight diffuser and mounting plate. Line up the three mounting holes and orient the parts so they match. The diffuser is symmetrical so it should line up with the mounting holes nicely.

Join Parts

The mounting plate should be flush with the headlight diffuser. Bring them close and press them together. If any warping occurs during the 3D printing process, the parts may has a gap which will introduce light leaking.

Secure Mount to Headlight

Insert M3 x 8mm pan head metric machine screws through the holes on the mounting plate. Fasten the screws until it barely protrudes through the other side. Grab the headlight diffuser and line up the mounting holes. Press the parts together. While holding parts, fasten the screws to fully tighten.

leds_plate-screw-holes.jpg

leds_plate-fins-screw.jpg

leds_plate-fins-installed.jpg

Hardware for Headlight Clips

Grab the metric screws and hex nuts for attaching the headlight clips to the mounting plate. You'll need 2x M3 x 10mm pan head metric machine screws and 2x M3 nylon lock nuts.

Install Headlight Mounting Clips

Grab one of the clips and press it into one of the square shaped tabs on the mounting plate. Reference the photo to gauge the correct orientation. Insert an M3 lock nut into the recess on the mounting clip – The hexagon shape would allow the lock nut to be press fitted. Fasten a screw through the tab on the mounting plate. Repeat this process for the second tab.

leds_tabs-bracket-join.jpg

leds_tabs-nut.jpg

leds_tabs-bracket-installed.jpg

Assembled Headlight

Take a moment to check your work. The clips should be flush with the tabs on the mounting plate.

Feather Mount

Feather Mounting Hardware

The mounting plate for the Feather has four standoffs with M2.5 mounting holes. These line up with the mounting holes on the Feather. Place the PCB over the mounting plate and line up the mounting holes. Use four M2.5 x 5mm flat head metric machine screws to secure the PCB to the mounting plate.

Secure Feather to Mounting Plate

Flat head screws feature a chamfered edge. Pan head screws (sometimes called button heads) have flat surfaces that require adequate space. The mounting holes on the Feather PCB have very little spacing so a flat head screw is ideal. If a pan head screw is used, it will cover up components like the chip LEDs. We suggest using a M2.5 tapping tool to create threads in the mounting plate. 

leds_feather-mount-installing.jpg

leds_feather-mount-installed.jpg

leds_feather-mount-installed-2.jpg

Case Assembly

Install Box Inputs

The button and toggle switch will be panel mounted to the 3d printed box. Remove the included hardware from them.

Install Button

Insert the cables from the button into the large hole on the side of the box. Press the button into the hole until it becomes flush with the surface of the box. Grab the button's hex nut and insert it through the cables. Twist the hex nut onto the threading of the button. Fasten the hex nut until it's fully tightened. A set of needle nose plier can assist in grasping the hex nut.

leds_box-button-installing.jpg

leds_box-button-flush.jpg

leds_box-button-nut.jpg

Install Switch

Place the toggle switch inside the box and fit the stem of the switch through the smaller hole. Press the stem through so the body of the switch is flush. Insert the washer and hex nut onto the threading of the toggle switch. Hold the toggle switch in place while fastening the hex nut. Fasten until fully tightened. A pair of needle nose pliers can assist in grasping the hex nut.

leds_box-switch-installing.jpg

leds_box-switch-nut.jpg

Feather Mount Hardware 

Two machine screws will be used to secure the Feather mounting plate to the box enclosure. These are M3 x 6mm pan head metric machine screws. Begin to fasten the two screws into the two small holes on the side of the box enclosure until the threading just barely protrudes through the other side.

Install Battery 

Inside the box enclosure is a circular clip that is sized for a 2200mAh battery. Grab the battery and begin to work it into the clip. Press the battery through the clip until it's fully enclosed in the box. Allow the JST-PH cable to sit outside the box.

leds_box-feather-install-screws.jpg

leds_box-battery-install.jpg

leds_box-battery-install-2.jpg

Secure Feather Mount to Box

Grab the Feather mounting plate and orient it so the two mount holes line up with the ones on the box. The bottom of the mounting plate should face the side of the box with the mounting holes. Insert the mount and begin to push it inside the box with the USB port facing the outside. Reference the photo to get an idea of correct orientation. About halfway through, plug in the battery into the Feather. 

leds_box-insert-feather.jpg

leds_box-battery-plug.jpg

Secure Feather

With the battery now connected, push the rest of the Feather mount into the box enclosure. Take a moment to adjust the wiring from the Feather. Insert and guide the cables so they are fitted nicely inside the box. Line up the mounting holes and fasten the two screws until fully tightened.

Feather Connections

Grab the JST connections from the Feather, button and switch and pulled them out so they're outside the box. Connect the JST cables with their corresponding cables. Be cautious not to mix up the 2-pin JST-PH connectors as the button and switch have similar connections. Take a moment to follow the wired connections to ensure the cables are going to the right ones. Leave the 3-pin JST-PH connector outside the box as it will be connected to the NeoPixels.

Attach Clips to Box

Grab the two clips for the box (bhl-box-clip.stl) and begin to attach them to the box enclosure. The box features a railing that allows the clips to slide into them. Orient the clips with the railing and firmly press it into place. Repeat this process for second clip on the opposite end of the box. If the tolerances are too tight, use a filing tool to loosen them up.

leds_box-clamps.jpg

leds_box-clamps-install.jpg

leds_box-clamps-installed.jpg

NeoPixel Test

Just as a precaution, go ahead and connect the 3-pin JST-PH cables together and toggle the switch on to test the circuit. The circuit should power on – Make sure the code is uploaded and set to the correct pin on the Feather.

Bike Assembly

Bike Frame

Take a moment to consider where you'd like to attach the box. On my bike, I clamped it to the bike frame near the head tube. This way it's away from my knees and easily accessible.

Attach Box Clips

Grab hold of the tabs and carefully pull them apart to widen the opening. Press the clip onto the framing of the bike (38mm / 1.5in diameter tubing). The clips should clamp onto framing. Insert a M3 x 10mm pan head machine screw through the hole in the tab. Use an M3 nylon lock nut to secure the clips. A socket wrench or pliers can assist in grasping onto the locknut while fastening. Repeat this process for the second clip. 

leds_box-clips-attach.jpg

leds_box-clips-locknuts.jpg

Bike Handle Bar

Take a moment to consider where you'd like to attach the headlight. On my bike, I attached them to the lower part of the handlebars.

Attach Headlight Clips

Following a similar process, pull the tabs apart from the headlight clips and clamp it onto the tubing. You might find it easier to do one clip at a time. Use another set of M3 x 10mm screws and M3 lock nuts to secure the clips onto the tubing. 

leds_headlight-clips-attach.jpg

leds_headlight-clips-locknuts.jpg

Final Form

And here's the final assembly! Take a moment to test out the placement of the clips by turning the handle bars, breaking, etc. Make sure the clips, headlight and box enclosure do not obstruct control of the bike – You're safety depends on this, so please consider it. I personally hit my knees a few times on the box enclosure because I placed it in the center of the frame. 

This guide was first published on Nov 06, 2018. It was last updated on Nov 06, 2018.