INTRODUCTION

It is seen that sensors are everywhere in our daily life. Some public street lights automatically light up during the day and automatically go out at night. Why?In fact, those lights make use of a photosensitive element that can measure the brightness of external light.

场景图

In the evening, when outside brightness becomes lower, the street light is automatically controlled to be turned on. When it is bright during the day, the street light is automatically turned off.

Component Required

器件组合图

Hardware Hookup

Ready to start hooking everything up? Check out the wiring diagram below to see how everything is connected.

光敏-P0

LED-P1

Insert the micro:bit into OSOYOO expansion board.

TEST CODE

If you are not familiar to make code, don’t worry. Firstly, you can enter this link:https://makecode.microbit.org/reference to know more about microbit blocks.
Then you can directly enter the https://makecode.microbit.org/ to edit your project program. Below is an example code we have done for you as reference.

Example Result

Done wiring and powered up, send the above code to MICROBIT. You should see the brightness data on the LED matrix of micro:bit.

If the brightness value is greater than 5, the light will be lit, otherwise, the light will remain extinguished.