SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By mrule968
Hello everyone -
I should start by saying I have very little knowledge of the topic I am asking about, but am in general fairly handy.

I have a 2007 Jeep Wrangler that I modified slightly to add a brake light plate behind the spare tire. The plate is a heavy aluminum plate that has 5 individual red LED lights mounted in a circle configuration, with all 5 LEDs wired to the 3rd brake light wiring. The LEDs all light up through the holes in the wheel when the 3rd brake light is activated.

I would like to try to create a controller that adds having the lights flash in a circular pattern for the turn signals, i.e. clockwise for a right turn and counterclockwise for a left turn, and possibly all flash with the hazard light activation. I foresee some type of controller that has 4 input triggers (brake, left turn, right turn, hazard) and 4 corresponding output options (solid on, counterclockwise flash, clockwise flash, all flash) to control the 5 LEDs. I also expect the controller would need to be housed in some type of weatherproof container with the input and output wire access sealed. I am imagining something like a very small pelican case attached to the interior body near the passenger tail light (easier access to run the wiring through the tailgate).

How far from reality am I wandering? Is this something that I could build, or have built relatively inexpensively? If I can figure out how to post a picture to this topic, I will do that. I live in the Westminster, Colorado area, and would be happy to meet with someone smarter than me that may want to help...
User avatar
By phalanx
This is certainly doable but there are some aspects of how the electrical system in a vehicle works that you need to consider.

The first problem is how do you get power for your device? When used as a brake light, you have power available as long as you have your foot on the brake. How do you handle the case of turn signals and hazard lights where power is being toggled intermittently? If you are ok with generating your pattern while the light is energized and have it reset during the off period, you may not have to do anything special with the power.

For your inputs, are you sure you actually have 4 inputs at the rear of your vehicle? I haven't looked at a Wrangler in a while but I seem to remember that the tail lights and brake lights are one in the same. This would mean that you only have 2 inputs into your controller (left bulb and right bulb) but their states relative to each other determine what mode you are in. Brake and hazard would look the same since both lights would be coming on at the same time. A left directional would only have the left light on and likewise for the right side. You would also have to consider how to handle having your brakes on and then turning on/off a directional or the opposite case of a directional being on and then turning the brake light on/off.

In terms of what to implement this on, any 8-bit microcontroller with enough I/O pins for your situation would be well suited to the job. While an Arduino would be easier if you aren't familiar with or have the development tools for stand alone controllers, the problem is the approximately 2 second delay in the Arduino bootloader before running user code. Unless you can find a steady 12V supply that's always on, an arduino will not respond fast enough from a cold start to be usable in your situation.

Weatherproofing is always a fun topic. Your pelican case idea would work assuming you can seal around the wires. Other options are to get small potting boxes and use electronic safe RTV to flood the area around the board. This is also good for shock proofing (mechanical shock) your board. I've also used liquid electrical tape from a hardware store to paint over the exposed traces and components which is more akin to a very thick conformal coating. There are plenty of ways you can approach this depending on what materials you can readily get your hands on.

Don't let this discourage you from your project. It just helps to have a better idea of everything that is going on during the planning phase so when you execute, there are less surprises that necessitate invasive rework of your electronics.

By mrule968
Hi Bill -

Thanks for responding. As far as getting discouraged, your post has done the opposite and energized me. It looks like the project is more realistic than I thought.

I believe you are correct in there only being a single bulb left and a single bulb right. I may have misspoke by saying input triggers. I've done a little more research, and I think the different triggers (or signals) are actually going to be based upon power status to the two turn signal wires (ignoring the marker light wire): both constant on (brakes), L constant/R pulsing (right turn), R constant/L pulsing (left turn), and both pulsing (hazard).

One of the questions I have is how to make the controller see the pulsing signal from the turn signal, vs. constant on from the brake signal. Can the controller be told to check both wires, wait a defined period and then check both again, and then output based upon comparison? Otherwise, it seems that the controller would interpret a brake signal anytime both signal wires are hot (every time the signal flashed it would revert to brake signal).

It seems that as long as both signal inputs were monitored by the controller, changing the status of the signal wire (adding signal after braking or vice-versa), could be adapted to by the controller. Is that wrong?

The controller is really where my heartburn is at with this project, as I know NOTHING about them.

For power, I was thinking I could run a separate dedicated power from an accessory fuse, so the controller would be supplied with 12v anytime the key is in the on or accessory position.

I'm pretty comfortable creating a container and weatherproofing. I've actually used RTV to seal wiring through pelican cases in the past with no negative consequences, and this enclosure would be mounted somewhere out of the elements as possible.
User avatar
By phalanx
One thing I overlooked that will definitely help you out is you have a 3rd brake light signal that should be independent of your tail lights. In any single mode of operation, it will be easy to determine whether a brake, hazard, or directional has been triggered. Where things get more complicated is when more than one mode is active at a given time. You will need to test every state and transition of possible mode combinations so you can handle them in software.

Don't worry about coding or hardware yet. Believe it or not, that's the relatively easy side of the equation. The hardest part is modeling the system you want to control. The better job you do, the easier it will be to implement the firmware. The hardware will not be very complicated for a system like this.

By mrule968
Okay, here is the point I get to show the true depth of my ignorance...modeling the system? Does that mean drawing out the wiring connections and possible states? I'm sorry for the lack of knowledge, and really appreciate all the help! I have no idea what the next step should look like...
User avatar
By phalanx
You are correct. Modeling can much more than a mathematical formula. To tackle a project like this, you need to know a number of things. For example:

What signals are available?
What states can they be in (including transitions between states)?
Are there any characteristics of the inputs that may require additional processing (like flashing)?
How many of them do I need to achieve my end result?
What are their electrical properties?
How do I connect to them?

What LEDs am I using and what are their drive properties?
How many LEDs am I driving?
How many output states do I intend to create?

This is not an all encompassing list but it's a good starting point for your system so you can start to appreciate the physical and software requirements of your project. The physical characteristics you identify like LED types, input voltages, total number of I/O, will help you in designing your controller. A number of people here can help you in that regard when you get to that point in the process.

On the software side of the equation, you would start by asking the question "How do I detect all of the possible input states that I've noted and identify them correctly." When you get to the point where you are ready to start coding, it can be somewhat daunting especially if you don't have a background in it. There are plenty of people here that can help you get started. Even if an Arduino ends up not being suitable for your application, I would highly recommend you buy one and start playing around with tutorials so you can start to understand what microcontrollers are capable of and how you go about getting them to do what you want.

As always, keep asking questions!

By mrule968
Here is what I came up with based upon your last post:
project .jpg
Here is a blurry pic (sorry) of the current lights:
To power the microcontroller, I intend to run a 12v power supply from an accessory fuse to the microcontroller, adding a resistor/regulator if necessary. That would eliminate the boot up delay for an arduino. I may be naive, but it seems I could do this project with 2 12v inputs (Right and Left), and 5 12v outputs (one for each LED to allow sequencing).

I have no arduino/programming experience at all, so I don't even know how to begin determining how to make it detect possible states and transitional states...

You do not have the required permissions to view the files attached to this post.
By mrule968
It looks like the 2nd photo was lost somewhere...trying again
You do not have the required permissions to view the files attached to this post.
User avatar
By phalanx
That's an excellent start to your project. I wish more people would write down details in that manner. It would help them and anyone providing assistance during the implementation stage.

If you intend to work though this on your own, you are at the point where you will need to start learning about some programming and electrical engineering concepts.

On the programming front, you would be well served by buying an Arduino since they are designed to be easy to use and implement. Sparkfun's Redboard (which is an Arduino) is more than suitable for your overall task and is very affordable at $20ish: There are countless tutorials available to help you get started learning the basics of programming. I've even come across code (Sketches in Arduino lingo) for tail light controllers that may possibly help you when you start to understand the fundamentals.

On the electrical engineering front, you will also need to learn how to interface your controller electronics with the outside world (your Jeep). Most microcontrollers operate at 5V or less so you need to take this into account when you connect to your vehicle's 12V electrical system which can also have large spikes and dips from that nominal value. The Arduino isn't set up to make easy connections to the outside world so you add piggyback circuit boards to them called Shields that have the necessary parts for making safe connections. Sparkfun doesn't appear to carry any shields that would be suitable for your task but a quick Google search shows a number of potential options. If you're ambitious, you can even make your own!

I hope you choose to see this through. You will learn a lot and have a new set of resources at your disposal for future projects!

By n1ist
One other suggestion - build a mockup of the jeep circuit on your bench (turn signal switches, a brake switch, flasher, some lights, and a 12v power supply). It will be a lot easier to develop and debug things using this instead of having to drag all of your gear out to the jeep. Junkyard or cheap import parts are fine for this.