How to Use Light Sensor With Arduino

Introduction: How to Use Light Sensor With Arduino

Energy conservation is now a days a soul need for our society.In order to implement it we are planning to make a project on saving electricity.In this project the LED will turn on when the light is dim and turn off when there is light.Broadly one can use this for the street lights which will help in saving a lot of energy.

Step 1: Gather All the Materials

Materials Needed are:

1.LED

2.LIGHT SENSOR

3. ARDUINO

4. BREADBOARD

5.BATTERY

Step 2: Make the Circuit

  1. Take the led and connect its small pin to gnd and tall pin to pin A0.
  2. Take the light sensor and connect small pin to ground and tall pin to analog pin A1.
  3. Connect your arduino to your laptop with usb cable.

Step 3: CODE

int sens = A1;

int led = A0;

float num,senss,leds ;

void setup(){

Serial.begin(9600);

}

void loop(){

senss = analogRead(sens);

leds = analogRead(led);

num = map(senss,0,1024,0,255);

analogWrite(leds,num);

}

Be the First to Share

    Recommendations

    • Pi Day Speed Challenge

      Pi Day Speed Challenge
    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Microcontroller Contest

      Microcontroller Contest

    Comments