Making "Police Lights" for Child's Bicycle

I am relatively new to the Arduino ecosystem and to microcontrollers in general, having made my way through the first 5 or 6 chapters of the Arduino Projects Book using an Arduino Uno.

I'd like to make some blue and red flashing LED "police lights" that I can attach to my son's bicycle handle bars. There is a section that is about 6 inches (15 cm) in length on his handlebar that I could attach the LEDs to.

For the LEDs, I was thinking of getting 2 of the NeoPixel 8x5050 RGBW LED sticks that I could put next to each other. I was hoping to also use a 3-way switch to toggle between flashing blue/red LEDs, set to all white, or to turn off.

This would have to be battery powered as well.

I'm willing to learn how to solder but don't have access to a 3D printer so I'd also appreciate any recommendations on how to assemble all of this.

I was hoping to get some recommendations on the hardware I should use and other considerations I should have. Specifically:

(1) Are there other LEDs I should look at?

(2) What's the best board to use that is compact, low power and is compatible with the Arduino IDE? I don't need bluetooth or wifi.

(3) What type of switch, battery holder or other hardware would I need?

(4) Any suggestions on how to mount the board and LEDs to bicycle.

I feel that this project allows me to build on what I have learned but to also stretch myself in areas that I'm not terribly comfortable with. This is my first post on these forums so thank you in advance for any suggestions!

I suggest using a plastic box having a transparent lid/top for housing the lot.

If You do Your best to make the box with its buttons as much water resistant as possible that toy will have a longer life.
Buttons covered with a membrane would a good chance to survive.

A plug, fitted downwards for charging would be handy....

Mounts for the handle bar of the bike.... Use U bent iron with threaded ends, a straight bar drilled and som nuts... Use Your fantasy! Visit a bike shop and se if any accessory can be modified and used...

Google WS2812B LEDs and you will be able to find lots of LED strips that you can just cut to length. There are varieties that come inside a plastic tube for water resistance as well. Pay attention to how many LEDs per meter there are. Some are 30 some are 60 which means they are closer together which would probably be better for your project.

Get an Arduino nano or micro to control them. Rather than a 3 way switch, just have a push button so every time you press it, it advances to the next pattern. This will give you a lot more options as you can build up all your different patterns beyond just red/blue/white. Check out the FastLED library to drive the LEDs. It has all sorts of examples that may inspire you.

The problem is powering WS2812 LEDs with batteries. You need 5 V; the only battery which provides this directly is a pack of four Ni-MH cells.

The power supply could be 3 AA cells with a boost regulator to 5 volts.

The power supply could be 2 AA to 6 AA with a step-up/step-down regulator to 5 volts.

Lotsa ways to go, see products at pololu.com. There are cheaper regulators available; be careful, specifications tend to be optimistic, just get one with plenty of current in excess of what you need. Like 2x.

The power supply could be a cellular phone "power bank" supplying 5 volts. They are cheap and can be small. If you get a few, you could charge them while one was working the circuit. This is also mechanically nice, as the power bank just disconnects at a USB jack for easy plugging and unplugging. Cannibalize an old USB cable for the connector.

Lucky kid.

a7

@Railroader: Thanks for the suggestions on how to mount it and keep it weather-proof!

@blh64: Thank you for suggestion the WS2812B LEDs. I've been looking at the NeoPixels from Adafruit which I believe is their version of these independently-addressable LEDs.

Regarding the boards: Is there anything smaller and cheaper that would get the job done?

Something like the Adafruit Trinket M0? The Arduino Nano and Micro are both over 20 USD.

Paul__B:
The problem is powering WS2812 LEDs with batteries. You need 5 V; the only battery which provides this directly is a pack of four Ni-MH cells.

Good point. I hadn't thought of that!

alto777:
The power supply could be 3 AA cells with a boost regulator to 5 volts.

The power supply could be 2 AA to 6 AA with a step-up/step-down regulator to 5 volts.

Lotsa ways to go, see products at pololu.com. There are cheaper regulators available; be careful, specifications tend to be optimistic, just get one with plenty of current in excess of what you need. Like 2x.

The power supply could be a cellular phone "power bank" supplying 5 volts. They are cheap and can be small. If you get a few, you could charge them while one was working the circuit. This is also mechanically nice, as the power bank just disconnects at a USB jack for easy plugging and unplugging. Cannibalize an old USB cable for the connector.

Thanks for the suggestions. Definitely something to think about. I think I'm going to have to break this project down into smaller steps to first get a prototype or something working on my desk and then think about power.

alto777:
Lucky kid.

Not quite. His old man still hasn't gotten past the Starter Kit projects, learned to solder, bought the LEDs, etc... :sob:

samirparikh:
Regarding the boards: Is there anything smaller and cheaper that would get the job done?

Something like the Adafruit Trinket M0? The Arduino Nano and Micro are both over 20 USD.

If you want to stretch, this is a good project to learn how to build off the development board. It's not very complicated in terms of the external hardware you'll need.

You can buy just the microcontroller itself for about 2.50 USD from the major retail suppliers (like Digikey and Mouser) For programming them, since you have an Uno you can use an ISP Shield in combination with the ArduinoISP sketch that comes included with the examples in the Arduino IDE. The Uno uses the ATmega328P as it's chip, which I linked you to.

There's any number of "Arduino on a breadboard" examples out there, but it's important to check what you will need. If you're powering this off of something like a USB powerbank for example, you won't need a voltage regulator since the power bank has one included. However you might need to build a workaround for the powerbank's auto-shutoff circuit. If you want to use single-cell batteries, 4 AA/AAAs would probably do you well enough without any other regulation circuitry.

Police lights are also probably not going to need a lot of speed to drive, so you could get away using the 8 MHz internal clock and not need the 16 MHz crystal.

Then you just need data for the unofficial "board". I downloaded Minicore (
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json) a while ago, and even though I've long since made my own custom boards file, this one looks just fine. Go the preferences, and paste that URL into the "Additional Boards Manager URLs" field, then download MiniCore with the Boards Manager. You can set options for your custom setup, most importantly the Internal 8 MHz clock option.

Be careful testing the circuit off a USB port. Those LEDs will use 80 mA each if you turn them on full blast. Just 7 of them will overload the 500 mA limit of most computer USB ports.

samirparikh:
Something like the Adafruit Trinket M0? The Arduino Nano and Micro are both over 20 USD.

Well, if you like to pay full price for a "genuine Arduino".

I wouldn't call this expensive however. :roll_eyes:

Aliexpress example

Jiggy-Ninja:

Be careful testing the circuit off a USB port. Those LEDs will use 80 mA each if you turn them on full blast. Just 7 of them will overload the 500 mA limit of most computer USB ports.

The rule of thumb usually specifies 60 mA. Strips vary quite a bit, but rule of thumb, so.

Yes, you can make them all turn on full brightness and draw some current. A strip of 8 would be 480 mA.

  1. Use a powered USB hub. If you draw too much current, no large deal.

  2. Don't do that. That is, don't turn on all the LEDs at full brightness for a long(er) time.

I have a strip of 61 LEDs. It has a chase pattern, perhaps 10 LEDs on brighter and the rest dim. It draws 150 mA.

Not full brightness, but plenty bright.

So. Do your circuit on the bench. Get the display you want working, then measure the current. You may be surprised to find that you don't need a 5 Amp power supply.

a7

Easiest battery power supply for a project like this would be a power bank. Comes with charger & boost circuit included. The quisecent current of those WS2812B LEDs may be enough to keep the powerbank from switching itself off.

alto777:
The rule of thumb usually specifies 60 mA. Strips vary quite a bit, but rule of thumb, so.

OP linked to RGBW LEDs. 4 colors per LED, so higher maximum current.

I am aware that the end result is likely to not have them all on at full blast. However, it’s possible for things like that to happen during testing. That’s why I said to be careful.

Jiggy-Ninja:
OP linked to RGBW LEDs. 4 colors per LED, so higher maximum current.

I am aware that the end result is likely to not have them all on at full blast. However, it's possible for things like that to happen during testing. That's why I said to be careful.

Yes. That's why I recommended a USB hub. So even if the USB specified over-current protection fails, all I will have destroyed is a USB hub.

And that's never happened. I've had the hub wink out, I've had a way too hot regulator on an ATTiny board, Arduinos struggling with reduced Vcc and so forth, but nothing destroyed.

Also: some power banks do not have a minimum current. Those that do can need a bit of current to keep them on - I know from recent esperience with one power bank that current can needs to be substantial.

Or worked around, there are keep-alive circuits OR you can actually do that with the Arduino, just another task to power up some higher-current load periodically. Good news, that can be quite a brief stab of current, google your friend for dets.

a7

RGBW LEDs sounds like gross over-kill for red and blue!


Broken link in the OP - the strip in question appears to be this one. :sunglasses:

However the more basic RGB only version wodul be more sensible for red and blue.

Jiggy-Ninja:
If you want to stretch, this is a good project to learn how to build off the development board. It's not very complicated in terms of the external hardware you'll need.

You can buy just the microcontroller itself for about 2.50 USD from the major retail suppliers (like Digikey and Mouser) For programming them, since you have an Uno you can use an ISP Shield in combination with the ArduinoISP sketch that comes included with the examples in the Arduino IDE. The Uno uses the ATmega328P as it's chip, which I linked you to.

That's cool! So what you're saying is that I can buy the actual chip by itself, pop it onto a shield, and then go from there? I've never used a shield before, but size wize, it looks to be about as big as a regular Uno?

Jiggy-Ninja:
There's any number of "Arduino on a breadboard" examples out there, but it's important to check what you will need. If you're powering this off of something like a USB powerbank for example, you won't need a voltage regulator since the power bank has one included. However you might need to build a workaround for the powerbank's auto-shutoff circuit. If you want to use single-cell batteries, 4 AA/AAAs would probably do you well enough without any other regulation circuitry.

Police lights are also probably not going to need a lot of speed to drive, so you could get away using the 8 MHz internal clock and not need the 16 MHz crystal.

Then you just need data for the unofficial "board". I downloaded Minicore (
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json) a while ago, and even though I've long since made my own custom boards file, this one looks just fine. Go the preferences, and paste that URL into the "Additional Boards Manager URLs" field, then download MiniCore with the Boards Manager. You can set options for your custom setup, most importantly the Internal 8 MHz clock option.

Be careful testing the circuit off a USB port. Those LEDs will use 80 mA each if you turn them on full blast. Just 7 of them will overload the 500 mA limit of most computer USB ports.

Awesome! Thank you very much for these pointers. I think I'll have to take it step-by-step and get some LEDs to playaround with first on my desk and then figure out the power supply. But when I do, I now have some good tips thanks your your comments!

Paul__B:
Well, if you like to pay full price for a "genuine Arduino".

I wouldn't call this expensive however. :roll_eyes:

I think I can afford that! Assuming I can learn to solder the header pins on, would something like this be compatible with the Arduino IDE (i.e. could I repurpose existing sketches I have for the Uno on this, assuming I can figure out which pins to connect to)?

alto777:
Yes. That's why I recommended a USB hub. So even if the USB specified over-current protection fails, all I will have destroyed is a USB hub.

And that's never happened. I've had the hub wink out, I've had a way too hot regulator on an ATTiny board, Arduinos struggling with reduced Vcc and so forth, but nothing destroyed.

Also: some power banks do not have a minimum current. Those that do can need a bit of current to keep them on - I know from recent esperience with one power bank that current can needs to be substantial.

Or worked around, there are keep-alive circuits OR you can actually do that with the Arduino, just another task to power up some higher-current load periodically. Good news, that can be quite a brief stab of current, google your friend for dets.

a7

@Jiggy-Ninja, @alto777: Thank you both for your comments. I'll admit that thinking about the power supply, what batteries to use, and ensuring that I don't draw too much current has started to make my head spin. I think that for now, I'll try to buy some of those NeoPixel LEDs and just get a basic circuit and light patter working using my Uno and a simple setup like this:

Once I've done that, I'll probably circle back here on next steps (see if there's a smaller board I can use, what power supply/battery pack to get). While this is more complicated than I originally thought, I'll try tackling it in smaller pieces. Thanks again for your comments!

Paul__B:
RGBW LEDs sounds like gross over-kill for red and blue!


Broken link in the OP - the strip in question appears to be this one. :sunglasses:

However the more basic RGB only version wodul be more sensible for red and blue.

Hi -- I was thinking of getting the RGBW strip so that I can do something with both flashing red/blue and also solid white (to use as a kind of headlight!) Thanks for pointing out the broken link. Sorry about that! Should be fixed now!

samirparikh:
@Jiggy-Ninja, @alto777: Thank you both for your comments. I'll admit that thinking about the power supply, what batteries to use, and ensuring that I don't draw too much current has started to make my head spin. I think that for now, I'll try to buy some of those NeoPixel LEDs and just get a basic circuit and light patter working using my Uno and a simple setup like this:

Once I've done that, I'll probably circle back here on next steps (see if there's a smaller board I can use, what power supply/battery pack to get). While this is more complicated than I originally thought, I'll try tackling it in smaller pieces. Thanks again for your comments!

This is a great idea. It is always a good idea to break a project down into small, incremental steps, especially while learning new things. Get the hardware for the circuit above. Get it connected. Get the NeoPixel examples working and understand them.
Wire in a button. (one side to ground, one side to a pin, configure the pin as INPUT_PULLUP) Figure out how to detect a button press (Look at the example in the IDE: File->examples->02.Digital->StateChangeDetection) Get that working.
Make the button change between 2 (or more) different patterns on the led. Get that working.
Finally, figure out how to power it all with a battery/power bank/etc. and how you want to weatherproof it all.

samirparikh:
That's cool! So what you're saying is that I can buy the actual chip by itself, pop it onto a shield, and then go from there? I've never used a shield before, but size wize, it looks to be about as big as a regular Uno?

Not quite. A "shield" is basically an adapter that sits on top of an Arduino to give it some new functionality. In this case, the ISP shield provides a big socket to hold a ATmega328P in so the Uno can be used to program other chips. Chips you buy loose will not come preinstalled with the Arduino software,

You don't technically need the ISP Shield to do this since you can just wire up the connections manually (it's only 6 wires), but the big ol' ZIF socket just makes it so much more convenient.

This is for later on in the project though, when you are working out how to mount it to the bicycle. Get your interface and LEDs all working properly first, then you can work out how to miniaturize it, mount it, and hook battery power to it. You might not even use bare chips anyway if you go the route of using minature clone modules like Paul__B linked to.