Car Headlight Arduino Photoresistor Sensor

825

7

1

Posted

Introduction: 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

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(){

Serial.println(analogRead(lightPin));

if(analogRead(lightPin) > threshold ){

digitalWrite(13, LOW);

Serial.println("LOW");

}else{

digitalWrite(13, HIGH);

Serial.println("high");

}

delay(100);

}

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.

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Paper Contest 2018

    Paper Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

Comments

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