Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES Buy from JP

In this lesson, we will show how to use the OSOYOO photoresistor module(Light sensor) to  to work with the OSOYOO UNO board, we will monitor the environment light   value from  this sensor,  then use the value to control LED light. When the light falls below a certain level, the Arduino turns on an LED.

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.

  1. OSOYOO UNO Board (Fully compatible with Arduino UNO rev.3) x 1
  2. OSOYOO Magic I/O Shield for Arduino x1
  3. Light Detect Module x 1
  4. LED Module x 1
  5. OSOYOO 3-Pin PNP cable x 2
  6. USB Cable x 1
  7. PC x 1

Firstly, please plug Osoyoo Magic I/O shield into UNO board as following:

Step 1) If you haven’t install mBlock software in your PC, please read Lesson 1, download and install the software.
Step 2) Run the mBlock PC software by double click the lovely Panda icon.   Drag and Drop osoyoo_uno_mext file(downloaded in Step 1) to mBlock software as following:

Now you will see a new device firmware in mBlock, see following picture:

Now mBlock software and OSOYOO_UNO device firmware have been successfully installed in our PC!

Now we will show you how to use blocks to turn above idea into reality.
Step 1: Click Control, then Drag and drop Forever block to programming area as following:

Step 2: Click Events,   add when Arduino Uno starts up block to the top:

Step 3: Click Variable,   make a variable and give it a name    brightness:

Step 4: drag a set brightness to 0 block to forever loop:

Step 5: Click Sensor category, add Read Light Sensor block to set brightness block:

Step 6: Click Control, Add If else  blocks below set brightness blocks:

Step 7: Click Operator, Add  “> 50”   blocks below set brightness block, then change   value  50   to 500:

Step 8) Click Variable, then  add brightness block to > 500 block field :

Step 9: Click Light , drag two pcs LED pin 13  blocks to if and else block, then change both pin number from 13 to 9, change lower LED value from HIGH to LOW  :

Now we have completed the block programming. The final block will be like this:

 Upload the program to Arduino

1)you need click the Connect button in the bottom of the mBlock software, you will see a USB window pop up,
2) select Show  all connectable device check box , then a device drop-down menu will show up,
3) select your Arduino port from device drop-down menu
4) click Connect button to  connect your PC to Arduino

5)After you PC is connected to Arduino UNO board,  please click Upload button in the bottom of your software, then the code will be uploaded to Arduino UNO board:

Test the program:
When you use your hand to block light over the light sensor, the LED will turn on. If you let sensor expose to light , the LED will turn off.