Note: ALL OSOYOO Products for Arduino are Third Party Board which is fully compatitable with Arduino


Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!


  1. Introduction
  2. Preparations
  3. Connection
  4. Upload Sketch
  5. Running Result


The OSOYOO Light Detect module incorporates a photocell, is a commonly used sensor in a wide variety of applications from DIY projects to industrial automation. Typically, the resistance of the LDR or Photoresistor will decrease when the ambient light intensity increases. This means that the output signal from this module will be HIGH in bright light, and LOW in the dark.

Photocells are sensors that allow you to detect light. They are small, inexpensive, low-power, easy to use and don’t wear out. For that reason they often appear in toys, gadgets and appliances. They are often referred to as CdS cells (they are made of Cadmium-Sulfide), light-dependent resistors (LDR), and photoresistors.

Photocells are basically a resistor that changes its resistive value (in ohms Ω) depending on how much light is shining onto the squiggly face.When it is dark, the resistance of a photoresistor may be as high as a few MΩ. When it is light, however, the resistance of a photoresistor may be as low as a few hundred ohms.  They are very low cost, easy to get in many sizes and specifications, but are very innacurate. Each photocell sensor will act a little differently than the other, even if they are from the same batch. The variations can be really large, 50% or higher! For this reason, they shouldn’t be used to try to determine precise light levels in lux or millicandela. Instead, you can expect to only be able to determine basic light changes.

This graph indicates approximately the resistance of the sensor at different light levels:

Light sensor is commonly seen in our daily life and is mainly used in intelligent switch, also in common electronic design.

To make it more easier and effective, we supply corresponding modules. Light sensor is a semiconductor. It has features of high sensitivity, quick response, spectral characteristic, and R-value consistence, maintaining high stability and reliability in environment extremes such as high temperature, high humidity.
It’s widely used in automatic control switch fields like cameras, garden solar lights, lawn lamps, money detectors, quartz clocks, music cups, gift boxes, mini night lights, sound and light control switches, etc.




Arduino IDE (version 1.6.4+)


First, please plug Osoyoo Magic I/O shield into OSOYOO basic Board:

Then connect the modules to the ports of the Magic I/O shield with two 3-pin PNP cables as below:

LED Module – D9

Light Detect Module – A0

Upload Sketch

After above operations are completed, connect the OSOYOO basic Board to your computer using the USB cable. The green power LED (labelled PWR) should go on.

Code Program

You can download the sketch from this link

In this experiment, we will connect a photoresistor to an OSOYOO basic Boardanalog input and read the value with the analogRead() function. Depending on the value the OSOYOO basic Board reads, the program will then set pin 9 HIGH or LOW to turn on or turn off the LED night lights. The threshold value is 512. When the analog value read is less than 512, the OSOYOO basic Board will turn the LEDs on. When the analog value it reads is more than 512, the OSOYOO basic Board will turn the LEDs off.

Compile and upload

Open the Arduino IDE and select corresponding board type and port type for your OSOYOO basic Board.

After compile this sketch, simply click the “Upload” button in the environment. Wait a few seconds – you should see the RX and TX leds on the board flashing. If the upload is successful, the message “Done uploading.” will appear in the status bar.

Running Result

If the room is lighted, the LEDs should not light. Try getting them to turn on it by covering the photoresistor with your hand. Remove your hand and observe that they turn off again.

In the same time, open the Serial Monitor and you will get the output data as below :


When you are using the Serial Monitor, please make sure the baudrate setting is same as your sketch definition.