Introduction: Car Headlight Arduino Photoresistor Sensor

Picture of Car Headlight Arduino Photoresistor Sensor

Be able to tell whether or not you headlights are on using an arduino and photo sensor

Step 1: What You'll Need

Picture of What You'll Need

1. Arduino *I used and Arduino Uno

2. Jumper Wires

3. Vehicle with manual head lights

4. Led

5. Photoresistor

Step 2: The Circuitry

Picture of The Circuitry

A current runs through A0 To the photo resistor which then sends so much current through depending on the amount of light that hits it. It then goes to ground and tell the Arduino whether or not to turn on the light depending on the thresh hold number.

1. Connect the photo resistor to ground and A0

2. connect the led to to ground an digital pin 13

* You may have to adjust the threshold to accommodate you're lights.

The code

int lightPin = 0; //define a pin for Photo resistor
int threshold = 17;

void setup(){

Serial.begin(9600); //Begin serial communication

pinMode(13, OUTPUT);

pinMode(A0, INPUT_PULLUP);


void loop(){


if(analogRead(lightPin) > threshold ){

digitalWrite(13, LOW);



digitalWrite(13, HIGH);





Step 3: Finish

Picture of Finish

Test your photo sensor using the serial monitor to get a sense of what your thresh hold needs to be. Now enjoy being able to sense light and have an led turn on.


tomatoskins (author)2016-05-19

What a great idea! Thanks for sharing and welcome to the community!

About This Instructable




More by swar468:Car Headlight Arduino Photoresistor Sensor
Add instructable to: