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

Table of contents


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.

Switch to turn the controller on/off


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 a 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.

Override switch for fog lights, RGB LED indicator

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 put too much load on the battery while starting the car.

Car with running lights (parking + fog lights)

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.

Car with high beams



  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

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


Main controller board, with voltage regulator, optocoupler and AVR
Override switch and RGB LED indicator
Module mounted under the dashboard
Signal wires connected to relays and sensing the built-in lights
Sense wires attached to built-in lights
Main controller board, with additional transistors

Source code

Schematic drawing

Car front lights controller schematics

Parts list

  • 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

Last commit 2021-06-09, with message: implement controller taxonomy