How to Use Light Sensor With Arduino

by Aryan222222 in Circuits > Arduino

289 Views, 1 Favorites, 0 Comments

How to Use Light Sensor With Arduino

save.jpg

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.

Gather All the Materials

materiasloghernhy5.png

Materials Needed are:

1.LED

2.LIGHT SENSOR

3. ARDUINO

4. BREADBOARD

5.BATTERY

Make the Circuit

Capture.PNG

  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.

CODE

arduino.jpg

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);

}