Skip to main content

Smart Light

Introduction

In this project, we will learn how to make a smart light that uses a light sensor to monitor ambient light. When insufficient light is detected, the system automatically turns on the LED light to provide sufficient lighting.

Teaching Objectives

Understand how to use light sensors

Master the basic programming skills of using micro:bit to control LED lights.

Teaching Preparation

Before starting teaching, please make sure you have prepared the following necessary materials:

PictureNameNumberNote
Smart Life Kit1
USB Cable1
micro:bit1Prepare on your own
PC1Prepare on your own

These materials will provide you with a complete experience, ensuring that you can smoothly carry out subsequent operations and learning. If you have prepared the above content, we can proceed to the next step.

Course Introduction

Some lights in public places are automatically sensed, and there is no need to press the switch by hand, which can save energy and reduce emissions. So how does this light realize intelligent opening? Can we make one ourselves?

Project Production

Hardware Connection

Connect the light sensor to the P1 interface of the Wukong expansion board, connect the rainbow light to the P2 interface of the Wukong expansion board, and insert the OLED display into the IIC interface.

Programming platform

We usually use graphical programming platform makecode to program micro:bit

Programming platform entrance: https://makecode.microbit.org/

Create a new project

Open https://makecode.microbit.org/

New Project

Enter a project name and click Create.

Add software library

Click Extensions in the Toolbox of the MakeCode programming interface.

Search for iot-environment-kit on the pop-up page and click to select the software library of iot-environment-kit.

Search for wukong on the pop-up page and click to select the wukong software library.

Write a program

Sample program:https://makecode.microbit.org/_cvA28PcpAWLJ

You can also download the program directly from the following web page.

How to download the program to micro:bit?

Use a USB cable to connect PC and micro:bit V2.

After the connection is successful, a drive named MICROBIT will be recognized on the computer.

Click in the lower left corner and select Connect Device.

Click

Click

In the pop-up window, select BBC micro:bit CMSIS-DAP, and then select Connect. At this point, our micro:bit has been successfully connected.

Click Downloader.

Results

After turning on, the smart light automatically turns on or off the rainbow light according to the ambient light intensity.

Extended knowledge

Application of smart light-controlled lights in life

Smart light-controlled lights are widely used in life. They improve the convenience, energy saving and comfort of lighting systems through intelligent control. Here are some specific application scenarios:

Home automation: In a home environment, smart light-controlled lights can automatically adjust the brightness and color temperature according to the daily living habits of residents, such as automatically reducing the brightness at night to create a comfortable sleeping environment, or gradually lighting up in the morning to simulate sunrise to help people wake up more naturally.

Energy-saving lighting: Smart light-controlled lights can automatically switch on and off according to changes in ambient light, such as reducing or turning off artificial lighting when natural light is sufficient, thereby saving energy.

Security lighting: In the field of security monitoring, smart light-controlled lights can automatically light up when abnormal activities are detected, which serves as a warning and deterrent.

Commercial lighting: In commercial environments such as shopping malls, supermarkets and office buildings, smart light-controlled lights can automatically adjust lighting according to the flow of people and time, which is both energy-saving and can meet the lighting needs of different scenarios.

Public lighting: In public areas such as streets, parks and squares, smart light-controlled lamps can automatically adjust the brightness according to the season, weather and time to ensure the uniformity and safety of lighting.

Educational lighting: In educational places such as schools and libraries, smart light-controlled lamps can provide appropriate light, reduce eye fatigue and improve learning efficiency.

Medical lighting: In hospitals and clinics, smart light-controlled lamps can provide appropriate lighting according to different medical activities and patient needs, such as providing shadowless lamp effects in operating rooms.

Hotel lighting: Hotel rooms can provide a variety of lighting modes such as reading mode and relaxation mode through smart light-controlled lamps to improve the comfort and satisfaction of guests.

Smart curtain system: Combined with the smart curtain system, smart light-controlled lamps can automatically adjust the brightness according to the opening and closing of the curtains to ensure the appropriateness of indoor light.

Emergency lighting: In emergency situations, such as fire or earthquake, smart light-controlled lamps can automatically switch to emergency lighting mode to guide people to evacuate safely.

These applications of smart light-controlled lamps not only improve the quality of life, but also help save energy and reduce emissions, and are an important part of modern smart home and smart city construction. With the advancement of technology and the increasing demand for intelligence among consumers, the application of smart light-controlled lamps will become more extensive and in-depth.