Automatic Headlight Dimmer For Vehicles Using Arduino

In this project design, we will be focusing on designing and constructing an automatic headlights dimmer for vehicles using an Arduino standalone board. Motorists face a huge problem due to high beam light which falls directly into their eyes when driving at night or foggy conditions and these problems include temporary blindness, glare, fading effect of image and sometimes causing accident leading to many lives and hence there is a need to design and construct a prototype of this device that automatically dims the headlights for on-coming vehicles to help solve this problem.

Automatic headlight dimmer for vehicles
Automatic headlight dimmer for vehicles

When driving, especially at night, headlights are crucial for visibility and road safety. High beams are used in pitch-dark conditions, while low beams are preferred in most other situations. However, in two-way traffic, the bright light from oncoming vehicles can cause glare, leading to temporary disorientation and increased risk of accidents. The proposed system automates headlight adjustments based on lighting conditions, reducing glare and enhancing safety by modulating the beam and turning off the headlights during daylight.

Components Needed for the Automatic Headlights Dimmer For Vehicles

The Atmega328P-PU chip used for the Arduino standalone board
The Atmega328P-PU chip used for the Arduino standalone board

The image above is the Atmega328P-PU IC chip that was used for the Arduino Uno standalone board. The building of the Arduino Uno standalone board allowed us to save cost on the project itself. You can read more on designing an Arduino Uno standalone board from the Arduino official website here.

  • Arduino Standalone Board
  • Light Dependent Resistor (LDR): To sense ambient light levels.
  • Infrared (IR) Sensor/Receiver: To detect oncoming vehicle headlights.
  • Relay Module: To control the switching between high beam and low beam.
  • Headlight Bulbs/LEDs: For simulating the vehicle headlights.
  • Power Supply (12V battery or 12V DC Power supply)
  • Wires, Breadboard, Resistors: For circuit connections.
  • NPN transistors

Read How To Design An Arduino Based Automatic Gate Controller

The Circuit Design

The circuit diagram for Automatic Headlights Dimmer For Vehicles
The circuit diagram for Automatic Headlights Dimmer For Vehicles

Principle of Operation

The basic principle of this circuit is, the various intensities of light i.e. high beam or low beam of headlight falling on the opposite vehicles headlight and the basic general idea of manual dipping and this same idea is converted into electronic format with this circuit.

LDR Sensor Placement: The LDR is placed in a position where it can sense the ambient light levels. It will detect whether it’s day or night.

IR Sensor Setup: We positioned the IR sensor to detect the headlights of oncoming vehicles. When the sensor detects bright light, it will signal the Arduino standalone board to switch to low beams.

Relay Module: The relay will be connected to the headlight bulbs. The Arduino will control this relay to switch between high and low beams based on the input from the sensors. But to make the headlight more responsive, we used an NPN transistor that would reduce the light intensity of the vehicle’s headlights depending on the light intensity of the oncoming vehicle’s headlights

Working Operation of the Automatic Headlights Dimmer Project

As seen in figure above, that the circuit diagram is divided into two parts, the power supply unit and the microcontroller connected to the headlight, LDR, RF transceiver module. The signal from the Light Dependent Resistor which is sent to the microcontroller is analog in nature, it ranges from 0 to 1023. The value of this analogue value measured by the microcontroller, determines if and when the headlamps of the smart car would dim or come fully on.

The source codes was made to work on when the analog value of the LDR is between 50 and 150 and if the RF transmitter of  another car is received by the smart smart car, it keeps the headlamp of our own smart car dimed but if the analog value of the LDR is above 150 and it keeps increasing, also the smart car doesn’t receive a Radio Frequency signal from the on-coming vehicle, it would dim its headlamp light for three seconds and turn it back fully on.

Hardware Implementation

An RF receiver module used in the Automatic headlights dimmer project design
An RF receiver module used in the Automatic headlights dimmer project design

The input voltage of the circuit is 12V. The needed voltage by the microcontroller is +5V while the headlamp requires 12V. A voltage regulator is needed to convert the +12V input voltage of the car headlamp into a +5V input source for the rest of the circuit. The microcontroller used is ATMEGA328P.

The Arduino Source Code

//include the virtual wire lib to enable the transmitter run
#include <VirtualWire.h>

//state the unsigned integer
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

//outline the characters used
const char *on2 = "a";
const char *off2 = "b";
const char *on3 = "c";
const char *off3 = "d";

//define the output signal 4rm the LDR
int lightSense = A0;


void setup()
{
 // Required for RF Link modules
 vw_set_ptt_inverted(true); 
// set data speed
vw_setup(300);
//making pin 8 the transmit pin 
 vw_set_tx_pin(8);
//set the receiver pin
 vw_set_rx_pin(7);
vw_rx_start();
pinMode(6, OUTPUT);

//make one pin ur input to sense/trigger our RF signal
//pls uncheck any input you dont want to use Michael
pinMode(3, INPUT);

}

//
void loop()
{
  
  int darkness = analogRead(lightSense);
  
  //set the condition for the transmiter to send out RF signal
if (digitalRead(3)== HIGH)
{
  // send this data out to the world
vw_send((uint8_t *)on3, strlen(on3)); 
vw_wait_tx(); 
// pause a moment
delay(200);
}
if (digitalRead(3)==LOW)
{
vw_send((uint8_t *)off3, strlen(off3));
vw_wait_tx();
delay(200);
}

if(darkness >=7 && darkness <= 650){ 
  digitalWrite(6, HIGH);
  
}

else if(darkness >= 651 && darkness <= 1010) {
  analogWrite(6, 32);
  delay(3000);
  digitalWrite(6, HIGH);
  delay(9000);
}
}

Explanation of the Arduino Source Code

The program syntax operates to automatically dim the headlamps on approach of  another smart car (whose source code is shown below). The reason for the RF transceiver modules attached to each test car models is to make them smart. So that they could be sending information as shown in the Arduino source code above. However, communication between a smart and a dummy car, maybe limited a little bit. What happens is that once the smart car detects the headlights of the dummy car, it dims its headlights for 3sec and turn back up for the rest of the way. This should allow ample enough time for the dummy car to pass the smart care

/* Program syntax to automatically dim the headlamps on 
 * approach of  another smart car to a smart and also notice  
 * a dummy car, dim for 3sec and turn back up for MCU 1
 */

//include the virtual wire lib to enable the transmitter run
#include <VirtualWire.h>

//state the unsigned integer
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

//outline the characters used
const char *on2 = "a";
const char *off2 = "b";
const char *on3 = "c";
const char *off3 = "d";

//define the output signal 4rm the LDR
int lightSense = A0;


void setup()
{
 // Required for RF Link modules
 vw_set_ptt_inverted(true); 
// set data speed
vw_setup(300);
//making pin 8 the transmit pin 
 vw_set_tx_pin(8);
//set the receiver pin
 vw_set_rx_pin(7);
vw_rx_start();
pinMode(6, OUTPUT);

//make one pin ur input to sense/trigger our RF signal
//pls uncheck any input you dont want to use Michael
pinMode(3, INPUT);

}

//
void loop()
{
  
  int darkness = analogRead(lightSense);
  
  //set the condition for the transmiter to send out RF signal
if (digitalRead(3)== HIGH)
{
  // send this data out to the world
vw_send((uint8_t *)on3, strlen(on3)); 
vw_wait_tx(); 
// pause a moment
delay(200);
}
if (digitalRead(3)==LOW)
{
vw_send((uint8_t *)off3, strlen(off3));
vw_wait_tx();
delay(200);
}

if(darkness >= 500 && darkness <= 650) {
 digitalWrite(6, HIGH);
}

else if(darkness >= 651 && darkness <= 1010) {
  analogWrite(6, 32);
  delay(3000);
  digitalWrite(6, HIGH);
  delay(9000);
}
}

The above source code is for the second smart car or second standalone Arduino board. This would make us to be able to pass information between each smart car about their proximity to one another during the night time.

Testing and Calibration

During the testing of this project, we simulate different scenarios. We tested the system in various lighting conditions like pitch black or street lighting, etc. And we found it to be working as we expected it to be. The programming worked also very well for the dummy car that was used to test a smart car model.

To calibrate the sensors, we had to adjust the sensor thresholds to ensure reliable detection and dimming at appropriate times. The allowed the project design to be more responsive to different light changes where it found itself performing.

Read Also Smart Window Automation: Arduino-Based System for Rain, Smoke, and Gas Detection

Conclusion

In conclusion, the “Automatic Headlight Dimmer for Vehicles Using Arduino” project offers a practical and effective solution to the problem of glare from oncoming vehicles, which is a significant cause of night-time accidents. By automatically adjusting the vehicle’s headlights based on ambient light conditions and the presence of other vehicles, this system enhances road safety and reduces the risk of driver disorientation. With its relatively simple design and the flexibility of Arduino, this project is not only a valuable tool for improving driving conditions but also a compelling demonstration of how technology can be leveraged to create smarter, safer transportation systems

We would like to know if you did this project. Let us know in the comments below. We would love to read from you. And please drop a question if you need any technical details dusted out for you.

Frequently Asked Questions on Automatic Headlights Dimmer Using Arduino

1. What is an Automatic Headlight Dimmer and How Does it Work?

An Automatic Headlight Dimmer is a system designed to automatically adjust the brightness of a vehicle’s headlights based on surrounding light conditions and the presence of oncoming vehicles. Using an Arduino microcontroller, sensors detect ambient light and the headlights of other vehicles, and the system dims the vehicle’s high beams when another vehicle is approaching, thereby reducing glare and improving road safety.

2. Why is an Automatic Headlight Dimmer Important for Night Driving?

An Automatic Headlight Dimmer is crucial for night driving as it prevents the blinding glare that can occur when two vehicles with high beams approach each other. This glare can temporarily blind drivers, leading to dangerous situations and increasing the risk of accidents. By automatically dimming the headlights, this system helps maintain visibility while ensuring the safety of all drivers on the road.

3. How Can I Build an Automatic Headlight Dimmer Using Arduino?

Building an Automatic Headlight Dimmer using Arduino involves setting up an Arduino microcontroller with light sensors (such as an LDR or photoresistor) to detect ambient light and the headlights of oncoming vehicles. The system then controls the brightness of the headlights using relays or MOSFETs. A simple Arduino code can be written to process the sensor data and adjust the headlights accordingly.

4. What Are the Benefits of Using an Arduino for an Automatic Headlight Dimmer?

Using an Arduino for an Automatic Headlight Dimmer offers several benefits, including cost-effectiveness, ease of programming, and flexibility in design. Arduino is an open-source platform with a large community, which means there are plenty of resources and support available. Additionally, Arduino’s versatility allows for easy integration with other vehicle systems and sensors, making it a popular choice for DIY electronics projects.

5. Can an Automatic Headlight Dimmer Help Reduce Night-Time Traffic Accidents?

Yes, an Automatic Headlight Dimmer can significantly reduce night-time traffic accidents by minimizing the risk of glare-induced disorientation among drivers. By automatically adjusting the brightness of the headlights based on real-time road conditions, this system enhances visibility for both the driver and oncoming vehicles, contributing to safer driving conditions during the night.

Leave a Comment

Follow by Email
Pinterest
Pinterest
fb-share-icon
Instagram
Telegram
WhatsApp