Introduction: Motorcycle Tail Lamp With Integrated Blinkers Using Programmable LEDs
This is somewhat an easy DIY on how to make a custom Programmable RGB Tail Lamp (with integrated blinkers/indicators) for your motorcycle or possibly anything using WS2812B (individually addressable leds) and Arduinos. There 4 modes of lighting patterns which can be cycled through using a push button.
The idea to make such a tail lamp had been there since the first day on which I got my motorcycle but at that time I wasn't sure of the method to follow on making one and didn't really have time as I was busy with my college. My initial plans were to buy RGB leds and replace them with the stock leds in the tail lamp of my motorcycle and do some rewiring to add the integrated blinker functionality. Such an implementation would have required a couple of transistors and voltage regulators for each of the RED-GREEN-BLUE control wires on RGB leds ending up with a very complex circuit.
However I was so obsessed with this idea, so I decided to buy the RGB leds and other components required, but all my plans changed when a guy at an electronics shop introduced me to a type of leds known as individually addressable or programmable leds(which was a new thing to me at that time) that were similar to RGB leds but each led can be controlled individually to light up in any sequence or color using Arduino controllers and only a single control wire for the whole strip. From there on it took me almost a year to complete this project starting from learning how these leds work...how to program them...going through different designs of the circuit and its prototypes...lots and lots of troubleshooting( this was the only thing that was happening for the last two months of my project as there were series of errors and component failures happening everyday as a part of my shitty design. While in the process of fixing some flaw in my circuit, new problems comes up and this kept on happening frequently and was a complete stress for me that it almost made me impossible to concentrate on anything else).By the end of this project I had gone through one damaged Arduino, couple of blown LM7805 IC and resistors, lots and lots of strip boards and leds all of which would add up to almost half of the money I spent on this project.
This project was something that I could have done or you could probably finish within 20 days provided that you have all the required parts at your disposal. What took me so long was because of my college, waiting period of the products which were ordered weeks or months apart as money was an issue for me and finally thinking to myself whether all of this was actually a stupid idea and what was the point of actually wasting my time and money on making this. Anyway I completely enjoyed doing this project and it kept me engaged for almost a year and I am sure you too will. So I welcome you to the DIY!
Step 1: Components Required
The components required can vary depending on how you plan to implement this project. For example I had used two Arduinos so that I can have multiple patterns and switch through these patterns. However if you only want the integrated blinker/indicator with brake light functionality you can do this with just one Arduino. Likewise the heat sinks used in my design were an overkill and was not required at all for my purpose. So you can eliminate those kind of components that you think isn't necessary, which I only used because I was dumb, inexperienced and was being over concerned(I still managed to destroy my circuit a couple of times). So below is the list of components I used for creating this project:
- WS2812B LEDs (depending on how much you require for your purpose)
- ARDUINO NANO x2
- LM7805 x5 (voltage regulator to convert 12v from battery to 5v)
- 10kΩ resistor x5
- Connectors (I used motherboard-smps connectors MALE(x2) & FEMALE(x2))
- Push button (to switch through modes) x1
- Strip Board x2
- Heat Sink x5
- Plastic Container x1
As I said, the parts required really depends on how you plan to implement this project.
Step 2: Arduino, WS2812B Leds and FastLED Library(Programming and Testing)
So the first thing that you need to do before making the actual circuit is to check whether your circuit design would actually work and whether your program will function the way it is supposed to. All of this can be done by testing out the components on a breadboard and if there are any issues with any of the components or the circuit. We can always retry with different options until we get the perfect working circuit. One of the reasons why it took me so long to complete this project was because of the reason that I was rushing with this project and didn't test the initial circuit design for different combinations of input signal. This ended up with having to go through a lot of component replacements as well as rewiring of the circuit.
The first thing to be discussed about is the kind of LED that was used in this project and how we can program them to function as we intend it to do. The model of the led that I used was WS2812B, generally known as individually addressable LEDs. There are various models of these LEDs with different names and I have no idea what's the difference between each of them, all I know is that different models differ in color temperatures and some them have a clock pin in addition to the data pin.
To control these LEDs we use the Arduino controller( I used UNO and MEGA for testing and NANOs for my final circuit) together with FastLED library, an arduino library used to control the kind of LEDs used in this project. This library can obtained from GITHUB REPO.
So the first thing to note before we can upload the programs to the Arduino is to add the FastLED library to the Arduino IDE. Steps on how to do this can be found here.
For this project I have used two Arduinos, one for sending signals to the LED and other to switch between different modes or patterns of lighting. If you only want a single mode/default pattern, one arduino is all that you require.
You can download the programs from the following link.
Now I will walk you through the programs and describe what all needs to be changed according to your setup. You can see that there are two programs called ledact and ledpatt2. Program ledact is for the arduino that is used to cycle through the modes/patterns and program ledpatt2 is the one that controls the leds. You can also see the the same two programs in different a folder called nano. It's thing but smaller in size so that you can use it with ARDUINO NANO which has less memory than UNO or MEGA.
First lets see what all needs to be changed in ledpatt2 according to your circuit. First you need to change the NUM_LEDS and DATA_PIN in lines 3-4 to the number of leds you are using and the number of the pin on arduino to which the data signal of your led is connected. Then you need to change the code in 18 according to the type of leds you are using. For example my code is like thta since I have used WS2812B leds with BRG(BLUE-RED-GREEN) calibration. If you are using any different led then replace WS2812B in the code with the name of your led and replace BRG with its color calibration. To find the color calibration of your led, you can follow the article found here.
You can see a couple of initialization from lines 15-25 of which 15-21 can be avoided if you only require a single pattern. These pins mentioned in lines 15-21 are used to trigger the different modes and this is done using the other Arduino. Lines 22-25 as it has been mentioned in the code, is used for taking the input signals for brake, park and blinker/indicator lights.
In ledact you only need to bothered about lines 4-8 if you want it to work just as it did for this project. Lines 4-7 are the pins that trigger each of the modes. Since I only wanted 4 modes, 4 pins were used. Line 8 is used to initialize the modePin, the pin to which the push button is connected. In the code you can see that arduino pins 3,4,5,6 are used for the 4 modes. These pins are directly connected to 3-4-5-6 pins on the arduino loaded with the ledpatt2 program.
This was my method of implementing leds lights with different patterns and I think it's pretty inconsistent. I searched a lot on the internet whether it was possible to do all of this using just one Arduino but I couldn't find any that helped me. If you know how to do so or is very good with programming, I suggest you go with it as my program is very badly intended and bulky due to my poor coding skills. And please do share your results with us.
Step 3: Circuit Setup
This is rather an easy step if you fully understand the circuit or has a well thought out plan for the circuit implementation. If the components in the circuit looks confusing to you, I will break it down for you as this is a very simple circuit. First we have five LM7805 ICs used to convert 12v to 5v(this voltage is safe for arduino input pins), four of which is used to take the signals of brake, park & L-R blinkers, other is used to power the two arduinos. Then we have a couple of 10k ohm resistors connected in parallel with each of the input terminals and finally two arduinos.
I made the circuit referring to the circuit design made prior using Fritzing. For connectors, SMPS-MOTHERBOARD MALE/FEMALE connectors were used. You can checkout the pictures and follow.
This circuit is not the best as it doesn't have any protection or filter circuits and the reason I didn't include any of this is because I am a complete noob. Also the heatsinks used with the ICs were taken off from an old SMPS and used thermal paste with them. However some electronic geeks told me that the use of heat sinks was an overkill for this application and that the ICs would operate without the need for any heat sinks in this circuit. So that's that.
Step 4: Final Step : Boxing and Setting Up in Motorcycle
Plastic container was used as the case for the circuit and wrapped insulation tape around it as water is something that we don't want in our circuit. Next job is to connect everything up and do the wiring on the motorcycle.You have to be really careful when working on the motorcycle electrical's as any shorting could completely damage the motorcycle's electronics. If you are not familiar with the wiring of your motorcycle, you can refer to your service manuals or search on internet. Remaining task is to remove your stock tail lamp and replace the LEDs inside it with the WS2812B ones. After that repack and reseal the lamp without leaving in holes or spaces for moisture to get in. You can keep the circuit box inside the storage space under the pillion seat of the motorcycle. Finally connect everything, power up and take your motorcycle for a ride. Though the project seems like too much work, I can assure you that the final outcome will make you joyous like a mad lad. THANK YOU FOR READING & ENJOY!