Automatic car head lights using Photoresistor ?

Hello everyone,

Like the title says I will like to accomplish this sort of project on my '01 Corolla. I don't know the circuit involved in my car's headlight switch as yet, but what I know is that it is a manual switch(obviously) so it toggles between some voltage and ground. I suspect it will be 5-12V for the switch.

Has anyone ever done this type of project using the photo-resistor and mind giving me any advice ? ( I have seen using a transistor)

I intend to power the arduino using the cigarette lighter.

Does anyone have any advice on circuit protection such as use of capacitors, fuses and resistors for this project ?

Thank You :slight_smile:

I can't figure from your post what you actually want to happen.

It would be common for car headlamps to be switched using relays. Presumably you could organize for the Arduino to control the relays with some suitable circuits to allow the Arduino to control 12 volts.

...R

Seems like a waste of an Arduino Uno, but once you have a prototype working, you can upload the sketch to an attiny45/85 and save the Uno for next project.

The daylight sensor for the headlights in my car is in a small module mounted on the inside of the windscreen behind the rear view mirror (along with the rain sensor for the wipers - no idea how that works - capacitive?). I guess being mounted there means the sensor is less likely to be confused by other vehicle lights.

You are going to need a small 5V regulator like 78L05 to run the attiny. A logic level power fet might be a good alternative to a relay for switching the 12V (it can be driven directly by the Arduino/attiny), but you need to know the current the lights will draw before you choose one (I guess around 5A total). If you stick with a relay, you will need a small transistor like bc337 to drive it. You will also need to wire up a manual/auto override switch so you can always get control back if it misbehaves on the road, and an extra fuse.

The sketch will need to perform smoothing and some hysteresis so that the lights don't flicker or respond to shadows of passing trees/buildings etc.

Paul

You need to disconnect the stock (stalk?) switch, and figure out what it’s doing. I assume it’s a simple multi-contact (off, parking lights, low beams).

Your car should be using a relay already, so you can trigger it with an NPN transistor amplifying one of your digital pins.

Hook the photo resistor up to an analog in with a voltage divider, install it where you want it, and calibrate it to the right level. You should probably use an on/off delay or hysteresis to avoid it strobing as you drive through trees and bridges.

Lastly, I’d install a failsafe that bypasses the uC altogether. Maybe the parking lights position can be “auto” and you can let the stock wiring from the headlamp on position go straight to the relay.

And please read the very last paragraph of the data sheet

SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: ...

You will be in serious trouble if your ATtiny decides to turn the lights off for whatever environmental reason (heat, cold, humidity, vibration...) while you are driving in the dark.
I use an ATmega to control my bicycle lights and I have experienced this at low speed, not funny :smiley:

What troubles me is the gross anti-social nuisance of "automatic" headlights.

Paul__B:
What troubles me is the gross anti-social nuisance of "automatic" headlights.

How so?
Until all cars have day driving lights that cannot be turned off automatic lights can be very helpful. The amount of times at dawn/dusk or in fog that other cars don't have lights on with the well I can see okay mentality.

Like the title says I will like to accomplish this sort of project on my '01 Corolla. I

Lights on/off or hi/lo?

If it were my project I would be inclined to parallel the light switch contacts with a tiny relay. - Scotty

Riva:
How so?
Until all cars have day driving lights that cannot be turned off automatic lights can be very helpful. The amount of times at dawn/dusk or in fog that other cars don't have lights on with the well I can see okay mentality.

Sorry, just my hobby horse. :grinning:

In my country, the vast majority of roads have a line marked down the centre.

Paul__B:
Sorry, just my hobby horse. :grinning:

In my country, the vast majority of roads have a line marked down the centre.

Ah, are you talking dipped/full beam? I’m just talking about the cars that don’t bother with any lights, even when they are clearly required.