7. Lesson 04 Photocell#

../../_images/MwngMAi.jpg

7.1. Introduction:#

Photocell is a kind of special resistor based on internal photoelectric effect. Its value of resistance is opposite to the brightness of the light, the brighter of the light is, the lower of the value of the resistance will be. Usually photocell is the core component of a photoswitch. In the following experiment, we are going to use photocell to control the brightness of 5*5 LED screen on micro:bit.

7.2. Components List:#

Hardware:#

  • 1 x micro:bit Board

  • 1 x Micro-B USB Cable

  • 1 x micro:bit Breadboard Adapter

  • 1 x Transparent Breadboard - 83 * 55 mm

  • 1 x Photocell

  • 1 x 10kΩ Resistors

  • n x Breadborad jumper wire 65pcs pack

Tips: If you want to buy all components above, then you will need Elecfreaks micro:bit Starter Kit .

../../_images/W4tseua.jpg

7.3. Major Components Introduction#

Photocell#

Photocell is a kind of special resistor made of semi-conductor materials like Cds or CdSe based on internal photoelectric effect. The brighter of the light is, the lower of the value of the resistance will be. with the intensity of light increasing, its resistant value decreased sharply, and the minimum light resistant value can drop down to below 1KΩ. Photocell is very sensitive to light. When there is no light, its resistant value arrives to its maximum and its dark resistant value usually can reach 1.5MΩ at max.

../../_images/jS03zGQ.jpg

7.4. Experimental Procedure#

Hardware Connection#

Connect your components according to the picture below:

  • 1.Connect the Photocell to P0 port.

  • 2.Connect the 10kΩ resistor with the Photocell in parallel.

../../_images/FtQDhiS.jpg

You would see as below after you finish the connection:

../../_images/TMd3Fq8.jpg

Software Programming#

Click to open Microsoft Makecode, write the following code in the editor.

../../_images/JHZUvh2.png

Program as the picture shows:#

../../_images/Hdxt7qd.png

Details for the code:#

  • 1.Analog read the voltage as the reference value for the brightness in “on start”

../../_images/Oj48CCS.png

  • 2.In the brick of “forever”, analog read the voltage from P0 port repeatedly. Once the voltage lower than reference value minus 2( it shows if the intensity of light increases, the resistant value of photocell would decrease), then it tells the light has been turned off. At the moment, an icon is showing on the micro:bit, the calibrationVal minus 2 is used to adjust the sensitivity, the lower value is, the higher of the sensitivity would be.

../../_images/bd9M5tC.png

Reference#

Links:https://makecode.microbit.org/_3tFFoPhLF7hX

You can also download the links directly:

7.5. Result#

Turn on the light, the LED screen on micro:bit shows nothing. Turn off light, the LED screen displays an icon.

../../_images/1Xu4lBR.gif

7.6. Elploration#

If we want to use photocell to control a LED, how to design circuit and program?

7.7. FAQ#