If you have ever cycled in Manchester, you’ll probably have regretted it. Audis, taxis, and Audi taxis threaten your very existence. To give them no excuse of not seeing me, I decided to build some novel, noticeable and unique lights for my bike.

Here’s my how-to guide for an easy, fun and satisfying evening project.

Overview

Essentially, this project consists of weatherproofing LED strips, fixing them to your bike, creating a weatherproof enclosure containing an Arduino and a (hacked) battery pack, and connecting it all up. All circuitry is in the enclosure, with only a connector to the LEDS, a charging port, and a button to turn them on and off exposed.

For this project, you will need:

  • WS2812B/WS2813 led strip, waterproof (AliExpress link)
  • Arduino – I chose an Arduino nano clone, but any will do.
  • Power bank – USB charged and USB powered.
  • 3+ core alarm style cable – a few meters.
  • An enclosure for your controller – must fit the batteries, charger board, and arduino.
  • 3+ pin plug and socket, and a switch.
  • Soldering equipment

Fitting your LEDs

I chose where I wanted lights to go: two strips at the back on either side of the frame, one small strip at the front and one strip under the frame to highlight my presence. Holding the LED strip to the frame, I counted the number of LED segments for each section. My LED strip consisted of the flexible circuit board itself, covered in a loose transparent rubber sleeve. To ensure that I had suitable weatherproofing at each end, I removed an extra LED section from each strip so the waterproof covering was longer than the internal PCB. The space at each end will be for the wire to join the LED strip, and will be filled with hot glue to reduce chance of water ingress.

With the LED lengths cut, the next step is to decide where you want your controller to go. I found the best place to put it on my bike was under the saddle, but other good places are by the handlebars or under your frame – you can choose wherever you want.

Then measure appropriate lengths of cable to link all the LED strip segments to the controller. If, like mine, you have LED segments at the front and on the main frame, you can save wire by joining the output of the main frame lights with the input of the front lights, as the LED strip is linkable.

Wiring up the lights

Using your cable, choose three colours to connect to your strip: I used red for +5v, yellow for data, and black for ground.

LED strip is directional so make sure you solder the wires from the Arduino to the side with data in, or “DI”. LED strips can then be chained up, by connecting the data out, or DO to the data in of the next strip, and so on.

Once soldered, test each strip by connecting to an Arduino and using an example sketch to make sure they work. I used the FastLED library, and uploaded “DemoReel100” to make sure I had everything working.

I then used a plug and socket connected to the LEDs, with a pin for +5v, Ground, and a pin per data line. This means the battery pack and Arduino can be disconnected to charge without having to take the lights off the bike.

On the Arduino, the +5v and ground lines to all LED strips should be connected together, respectively. The Arduino will be powered from VIN and Ground pins which will be connected to the respective power lines as the LEDs, meaning that the power to the LEDs doesn’t go through the Arduino – the Arduino just generates the signal to instruct the LEDs to illuminate.

Give me power!

To power it all up, I hacked the power bank by removing the battery and control board within, carefully placing it into the controller case. To charge the battery without playing with the charging circuitry, I cut a USB A to micro-USB cable in half, plugging one end into the power bank, and soldering the 5v and ground wires to a 2.5mm jack socket on the outside of the box. The jack is purely there as it’s more weatherproof than an exposed USB socket.

I used the other end of the cut USB cable to plug into the power board, with the wires going to the +5v and Ground wires mentioned above.

I fitted a water resistant button to the case which connected to the button of the hacked power bank – press once to turn on, and press and hold to turn off. I also added a socket for the LEDs, which enables a secure and reasonably weatherproof connection.

Finally, centre the LEDs in their weatherproof covering, and fill each side with enough hot glue to create a good seal – while it won’t be absolutely water tight, it will prevent rain getting in.

The Code

Once you have everything hooked up, it’s time to flash the Arduino so the lights illuminate as you want. You can have all sorts of effects, from rainbows if that’s your thing, to flashing front lights, animated back lights – it’s up to you.

I wrote a simple sketch to set the main frame and front lights to white, with animating back lights. I’ve put it on GitHub – feel free to use and hack:

https://github.com/conorriches/bikelights

The code is simple – we initialise FastLED, register four LED strips and assign a pin to each strip, and then in our init method, set main and front lights to white, and in the loop method, we animate only the back LEDs.

 

Hacking it further – adding indicators

I’ve designed so it’s easy to add indicators, useful if you want to make it even more obvious which way you’re turning, especially if you have a pannier basket.

Doing this is simple: you’ll need a switch (or switches) on the handlebar capable of defining three situations: turning left, turning right, and off. Connect the switches to the controller is straightforward, check out this nice tutorial if you haven’t done this already: https://www.arduino.cc/en/Tutorial/Button

Then in in the loop method of your Arduino sketch, check the status of switches – and depending on the state, set a blinking indicator or clear it.

You can do all sorts of other stuff, such as make the animation change with speed by adding a sensor to a wheel, or add a sensor to your brake levers so cars behind can see when you’re braking. Don’t make the lights flash blue though, even if it gets you home quicker, you might get in trouble for that…

Disclaimer

Please note – this project is fun.  The best way to protect yourself is proper cycling lessons, defensive cycling and good road position. This project is not a replacement for legal cycling, proper hand signals, and proper bike lights. As well as my fancy bike lights, I also have a white and red one that I bought, and are to standard. DIY projects may break sooner that proper bike lights and if you have no lights, you must not cycle on the road in the hours of darkness. Be safe out there!

Categories: ArduinoWeekendProject