Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.

Why Join?

  • Expert Support: Solve post-sale issues and technical challenges with help from our community and team.

  • Learn & Share: Exchange tips and tutorials to enhance your skills.

  • Exclusive Previews: Get early access to new product announcements and sneak peeks.

  • Special Discounts: Enjoy exclusive discounts on our newest products.

  • Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.

ūüĎČ Ready to explore and create with us? Click [here] and join today!

2.26 Photoresistor¶


In this lesson, you will learn about Photoresistor. Photoresistor is applied in many electronic goods, such as the camera meter, clock radio, alarm device (as beam detector), small night lights, outdoor clock, solar street lamps and etc. Photoresistor is placed in a street lamp to control when the light is turned on. Ambient light falling on the photoresistor causes street lamps to turn on or off.

Components Required¶


Fritzing Circuit¶

In¬†this¬†example,¬†we¬†use¬†analog¬†pin¬†(¬†A0¬†)¬†to¬†read¬†the¬†value¬†of¬†photoresistor.¬†One pin of photoresistor is connected¬†to 5V,¬†the other is wired up to A0. Besides, a 10kő© resistor is needed before the other pin is connected to GND.


Schematic Diagram¶




  • You can open the file 2.26_photoresistor.ino under the path of sunfounder_vincent_kit_for_arduino\code\2.26_photoresistor directly.

  • Or copy this code into Arduino IDE.

After uploading the codes to the Mega2560 board, you can open the serial monitor to see the read value of the pin. When the ambient light becomes stronger, the reading will increase correspondingly, and the pin reading range is „ÄĆ0„Äć~„ÄĆ1023„Äć. However, according to the environmental conditions and the characteristics of the photoresistor, the actual reading range may be smaller than the theoretical range. For a detailed explanation of the code, refer to 1.5 Analog Read.

Phenomenon Picture¶