With a photoresistor you can acquire the amount of light in your ambient.
You could use this value for several different purposes, for example you can turn on the lights when the sun sets at evening or you can turn them off when the sun rises at morning.
This simple sketch show how to retrieve this value
BOM (Bill of material)
1 Arduino
1 Photoresistor
1 10kohm resistor
Connect the photoresistor and the resistor to your arduino board as follows:
Connect your arduino board to your PC and burn the following sketch:
int photoResistorPin = 5; int photoResistorValue = 0; void setup() { Serial.begin(9600); pinMode(photoResistorPin, INPUT); } void loop() { photoResistorValue = analogRead(photoResistorPin); Serial.println(photoResistorValue); delay(500); }
connect to the Arduino board through the Serial Monitor on the Arduino IDE, on the serial line you should see something like the following few lines:
257
251
241
234
233
230
227
245
913
936
941
942
943
943
At first my photoresistor was covered with a cartoon box 😉 then I removed the box and immediately the value rised. You can try moving the box slowly and you’ll see a slow variation in the values printed on the serial line.
Gg1