Car Headlight Arduino Photoresistor Sensor




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

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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

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

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.

Sensors Contest 2016

Participated in the
Sensors Contest 2016

First Time Author Contest 2016

Participated in the
First Time Author Contest 2016

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest



    3 years ago

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