Ambient light controlled LED Driver

Hey guys I'm working on a project for my car and have all the hardware laid out. However I need a push in the right direction as far as programming goes. This is a very long post and I thank/appreciate everyone in advanced for reading through it....or at least clicking on the link!

I'm designing a custom LED angel eye setup for my car and want the LEDs to be controlled via a logic board using an ambient light sensor. When it is daylight out, I want the LEDs to be you can see them in daylight. As night falls, I want them to dim according to the ambient light detected. I also want to program a delay in so that the LEDs do NOT dim right away under overpasses, etc.

My plan is as follows:

I will be using Cree X-Lamp SMD LEDs. They will be glued to the back of acrylic rings using clear RTV silicone. The LEDs will be wired in parallel with each other.

I will be soldering about 450 of the LEDs across 4 rings. 2 rings per headlight. The rings will be wired in series to an LED per headlight.

Here are the LEDs:

Lux Drive Buck Puck Driver 3023-D-E-1000PmA:

I'll be using an Arduino Pro Mini:

A FDTI Breakout board for programming:

And a TEMP6000 as the ambient light sensor:

Now. The driver has a REF output which is regulated at 5V...perfect for powering the logic board. I will be using a 12ohm resistor inline with the positive lead of the driver to eliminate errors in my car. The REF output will go to the arduino board's VCC? (I think that's what it's called) to power it. And a CTRL input from the driver will be wired to the arduino board. Do I use an analog or digital port?

Now that everything is wired. On to the programming. I found this basic code and wiring diagram on here:

But I see the TEMP6000 is wired to the 5V pin on the arduino. Don't I need that port to power the board (from the driver)? If so, can I use the other 5V REF output on the other driver to power the TEMP6000? The sensor will be located above my rear view mirror, next to the existing photo sensor there used for auto wipers. Should I just wire a separate power supply, closer to the sensor? The driver's will be located inside the headlights. I was planning on mounting the arduino board in the ECU box of my engine bay.

Anyway, the code is as follows:

int temt6000Pin = 0;

void setup() { Serial.begin(9600); }

void loop() { int value = analogRead(temt6000Pin); Serial.println(value);

delay(100); //only here to slow down the output so it is easier to read }

Serial port to 9600? I'm guessing this is a standard/constant I do not need to worry about? The site also mention that the values will be from 0-1023; 0 being the lowest, 1023 being the highest. Where is that value displayed? In the first line? So does it change?

Also this is just the reading from the sensor. How do I use it to control the driver? I think I would use PWM? And the values would be from 0-255; again 0 being the lowest, 255 being the highest.

I know I need to specify ports. For example, the ports which the drivers will be on and the analog port which the TEMP6000 will be on. But I'm lost relating them to each other. Can somebody make a basic code for me? Or at least explain where to go from here?

I just started programming in one of my electrical engineering classes so I am a newb at programming. But this logic board got me so interested in using the sensor to control the LEDs!

I've been reading the guides on the main Arduino site about programming. But it's all #'s and letters to me.

Again thank you guys for reading!

KE7GKP: I would have serious concern for heat sinking. Are you doing anything about that? There are extensive discussion in the documents about the importance of heat sinking, but your proposed design seems completely devoid of anything that will keep the LEDs at a safe temperature. IMHO, that is a fatal flaw in your plan, at least as you have described it.

Are you sure about that? That seems contrary to most LED circuit design principles I have studied.

Wow! I was not expecting such a quick and detailed reply. Thank you! This project has already been done on;

All the hardware is the same with the exception of the potentiometer. I'll be using the logic board in place with the TEMP6000 sensor. SMD LEDs generate very little heat. I understand the concept of heatsinking and it's need to keep the efficiency of LEDs up and to increase longevity/life expectancy of the LEDs.

I've been in contact with this individual and he wired the LEDs as I mentioned.

What "logic board" are you referring to? the 20mA limit from that output certainly isn't enough to power any Arduino board.

I was referring to the Arduino Pro mini. So I read later in your post that I can just run it off 12v power from the car. I will do that instead.

Huh? Where did that idea come from? Do you have any references to your documents that supports this scheme?

This is a trick in the automotive industry. The OEM halogen housing consumes 35W. Using P=VI and P=VI^ get a resistance value of 11.9999. I can round that off to 12ohms and using that inline with the positive lead on the driver's to trick the car into thinking it has a functional halogen bulb installed.

I can do that or program my car and code out the cold and warm bulb check systems. However, when other units go out, I will not be notified.

Depends on other details not in evidence.

I think I may have answered my own question later in my original post. If I use PWM, I would use of those ports on the pro mini.

I don't understand what that means? If "everything is wired", then why do you seem to have questions about the wiring?

I meant figuratively speaking. Now that I'm finished talking about the wiring. I guess I should have phrased that better.

OK, that TEMT6000 gadget appears to be a photo transistor and a resistor on a tiny board. $5 seems rather steep for such a simple thing, but Sparkfun is good at selling simple things at premium prices. More power to them. The "code" consists of measuring the voltage at an analog input pin. Seems pretty basic stuff.

It suppose to mimic the sensitivity of the human eye. I outputs a very even signal and that's what I need for my project. Using a regular photo diode or similar would not accurate enough. For only $5 why not? I only need one.

The TEMT6000 board needs power, and the +5V pin on Arduino is an ideal source of power for a sensor like that.

I now understand that I can use the 12v power from my car to power the arduino. I though I need a regulated 5V to power it. However, you clarified this later on.

1) A power node can have a source and many loads all connected together. There is nothing unusual about that. 2) I don't really grasp your powering scheme from your verbal descriptions. It is time to draw a diagram.

So you have changed my plan a bit. I will work out a diagram with the new plan and post it here.

Don't plan on using that driver REF output to power ANYTHING. Its current output is WAY to low to use for your proposed project. Arduino can be powered from the vehicle 12~13.6V battery using the VIN pin which makes use of the regulator on the Arduino board.

This saves me alot of wiring!

The sensor takes very little power. Running a very small 2-conductor shielded wire should be adequate for connection to the ground, power, and signal output nodes. I would use the +5V pin on the Arduino to power this kind of sensor. The Arduino +5V output is ideal for this kind of application.

If I mount the pro mini in the ECU box like I proposed before, I will only need to run about 6ft of wire to the rear view mirror cluster. Perfect.

Experiment with each device separately, learn how to connect it to Arduino, and then learn the code it takes to talk to them. If you take these as separate little sub-projects, it will be easier to integrate them all together. See what raw values you are getting from your setup, and then you can use map() or other techniques to make the numbers come out right. Should not be a significant issue.

Not sure what map is. I will research that some more. If you want to explain it, that would be nice. :) But I understand if you don't want to. I'm sure it has been covered before. I'm not new to forums....I have about 5,000 post on :)

So start out with simple things and build up from that. There are lots of great tutorials on this website that guide you through all the basics of both hardware interfacing, and writing code to talk to various things.

Start out with one thing at a time and learn how to use it with Arduino.

My opinion is that you are starting with a very large and complex project for your stated level of understanding. If you screw up something, it will be very easy to toast some expensive hardware before you even know what happened. At least learn how to draw electronic schematic circuit diagrams and plot out your whole project on paper. If you do that and share it here, dozens of very experienced people can help your avoid errors and expensive mistakes.

I will most likely have to do this. I haven't gotten all the hardware yet. I'm just trying to get a grasp on things before I order everything. I have worked a bit with the Arduino UNO in my mechatronics class but nothing this complex. Also, I'm currently retrofitting a LCI M-sport bumper on my pre-LCI E90 330xi and so this is consuming most of my time now. Preping the bumper, making the kidney grills fit, painting, and mounting it.

I also want to mention that I will be using a bosch relay to turn things on. Most likely wired to my cigg lighter because it is ACC switched.

Can the ardiuno power up and power down the drivers?

My plan as of now is to wire the drivers directly to the battery with the bosch relays but if I can power up/down the drivers with the arduino, that would be ideal.

This convenient function allows you to take whatever range of values come from your input sensors, and transform it into the range that you want.

Thanks. Sorry for the late response, I’ve been a bit busy.

Well, if they say so. I took that as simple commercial puffery. I’m not convinced that any old photosensitive gadget (photo-transistor, photo-diode, photo-resistor) wouldn’t work just fine.

Yea I mean it’s only $5 so I’m going to go ahead and use this.

I’m not sure what the relay will do for you. Unless you think you need some sort of “fail-safe” disconnect in case your circuit catches fire or something.

I didn’t read every word of the documentation for the drivers, but my impression was that they could be controlled down to zero. And that should mean that Arduino can control the system all the way down to “off”. The only unknown is what kind of little transients might happen during power-up. That might be a bigger issue WITH the relays than hard-wired. And not a serious show-stopper in any case.

Well I was going to use the bosch relay to turn on the board. If I’m going to wire them directly to the battery, then I don’t want it on all the time. If I wire in the bosch relay, I can have it turn on with a switched power source…such as the cigg lighter. Of even the footwell lights so they function as welcome lighting (LEDs fade on when you unlock the car and fad off when you lock it).

I just order the board and all the rest of the hardware so I’ll be working on this soon. I’ll keep you updated on my progress. Thanks!