Car front lights controller

From CaveLab
This page is kept for historical interest. It may document projects or methods that are obsolete and/or no longer relevant. The information here is not kept up-to-date.

This car has been scrapped.
Car with running lights
Car with high beam

Lights controller for high beams and fog lights on my Subaru. Uses an AVR ATtiny2313 microcontroller.


This unit is used for controlling additional car headlights, such as high beams and fog/running lights. The module also controls a RGB LED on the dashboard, indicating the status of the lights and used as a alarm LED. It's connected directly to the cars battery, and sensing the status of the cars built-in park light, low beam and high beam.


Fog/running lights

The fog/running lights are controlled in such a way that they do not violate Norwegian law. Meaning; they can only be on during the day and must be used together with the parking lights. They can not be used together with low or high beam. Using the switch it's possible to still use the fog/running lights together with the low beam, but this is only permitted in extreme weather conditions or fog. The fog/running lights are turned or kept on for one minute after the car has been turned off, to illuminate the front of the car in dark situations. They also have a three second start up delay, so not to

High beam

The high beam is activated together with the cars build-in high beam lamps. If the fog/running lights are on they will be turned off, even if just using the headlamp flasher. The use of fog/running lights together with the high beam is according to Norwegian law only permitted when running at low speed (5-15 mph), but this combination is not possible.



  1. PD0 Parking lights
  2. PD1 Low beam
  3. PD2 High beam
  4. PD3 Switch


  1. PB3 Green LED indication
  2. PB4 Blue LED indication
  3. PB5 Signal active
  4. PB6 Fog/running lights
  5. PB7 High beam

Wire connection

# Color Function
1 Red 13.8V +
2 Black 0V
3 Green Parking lights in +
4 Brown Parking lights in -
5 Yellow Low beam in +
6 Gray Low beam in -
7 Purple High beam in +
8 White High beam in -
9 Pink Switch in +
10 Blue Switch in -
11 & 12 Yellow (separate) Relays fog/running lights and high beam out -
13 Red (separate) Green LED indication
14 White (separate) Blue LED indication
15 Yellow (separate) Signal active

LED indication

A RBG LED is used for indication of which lights are active.

  • Red High beams
  • Green bright Running lights
  • Green dimmed Fog lights
  • Blue Alarm LED

Wire connection

# Color Function
1 Yellow 13.8V +
2 Brown Red -
3 Green Green -
4 White Blue -

Source code

Bascom-AVR source is available in a git repository:


Schematic drawing


Parts list

Qty. Part
1 × AVR ATtiny2313-20PU, DIL-20, 20 MHz, 18 I/Os
1 × Capacitor, aluminium electrolytic, 10 µF, 25V
2 × Capacitor, aluminium electrolytic, 47 µF, 25V
1 × Capacitor, ceramic, 1 nF, 100V
1 × Capacitor, metallized polyester foil, 10 nF, (0.01 µF)
2 m Control cable, 10-cores, 0.14mm2, 250 V, Ø 5.4mm
2 m Control cable, 4-cores, 0.25mm2, 250 V, Ø 4.6mm
1 × DIL socket, 16-pin, 7.62mm
1 × DIL socket, 20-pin, 7.62mm
2 × Diode, rectifier, 1 A, 400V, 1N4004
1 × Enclosure, plastic (1551), 35x35x15mm
1 × Enclosure, plastic (1591 FL), 100x50x25mm, flange
1 × Fuse 5x20 mm, 500 mA, fast-acting
1 × Fuse holder, wire, 5x20 / 6.3x32mm
1 × Heatsink, 27.3K/W, 19mm, attachable, TO220
1 × LED 5mm clear, RBG, 2.1 3.3 3.4V, 20mA, 25°
1 × LED lens 5mm, CLB 300 low, Clear
1 × Optocoupler, 4-channels, PC817
32 cm2 PCB, stripboard, 100x160mm, 160cm2
4 × Resistor, carbon film, 0.25W, 330 Ω, 5%
1 × Resistor, carbon film, 0.25W, 680 Ω, 5%
2 × Resistor, carbon film, 0.25W, 1.8 kΩ, 5%
6 × Resistor, carbon film, 0.25W, 4.7 kΩ, 5%
1 × Resistor, carbon film, 0.25W, 6.8 kΩ, 5%
4 × Resistor, carbon film, 0.25W, 10 kΩ, 5%
4 × Resistor, metal film, 0.6W, 1 kΩ, 1%
12 × Straight pin header, female, Single row, 2.54mm
14 × Straight pin header, male, Single row, 2.54mm
1 × Switch, toggle, 1-pole, micro, on-on
15 × Terminal block, screw, 2.5 mm
5 × Transistor, NPN, 100 mA, 45V, 0.5W, BC547B
1 × Voltage regulator +5V, 2 A, L78S05CV
14 m Wire, stranded, 0.50mm2, Yellow