X
Home > Blog > STEM for Arduino > HOW to Make an Automatic Lighting System with KidsIOT
HOW to Make an Automatic Lighting System with KidsIOT
By r September 19th, 2024 24 views
Herein, we combine the photoresistor and LED module to design an automatic lighting system.

Flow

4201

Assembly

line1

Required:

42_00

line1

Step 1

42_01

line1

Step 2

42_02

line1

Step 3

42_03

line1

Step 4

42_04

line1

Step 5

42_05

line1

Step 6

42_06

line1

Step 7

42_07

line1

Step 8

42_08

line1

Step 9

42_09

line1

Completed!

42_10

line1

Wiring Diagram

4202

Test Code

Open KidsBlock and connect to the board, click File –> Load from your computer.

3111

Choose D:\Code\2.Code_kidsIOT to open 4.2Automatic_lighting.sb3

4203

Click 3209 to connect to the port and then 2210.

Explanation

5top

Code Blocks

Blocks

Code block

Events

begin

P

setmode

P

readanalog

P

setout

Serial

serialbegin

Serial

serialprint

Operators

![less than](media/less than.png)

Control

forever

Control

ifelse

Control

wait

line5

Conceive:

  1. Initialization

    Set the pins of white LED module and the photoresistor; Initialize the serial monitor.

    4204

line3

  1. Main Code

    Loop:

    ① Print the value read by the photoresistor.

    ② Determine whether the photoresistor value is less than 1000 every 0.1s.

    • value < 1000 (weak light): LED lights up.

    • value ≥ 1000 (adequate light): LED goes off.

    4205

5bottom

Test Result
4top
Upload code and the photoresistor starts to detect the ambient light intensity.
In room, when the light is sufficient (the value is greater than 1000), the LED is off.
When the ambient light is weak (the value is less than 1000), the LED is on.
In the code, the threshold value 1000 can be modified according to your needs.
4206
4bottom
HOW to Make an Automatic Lighting System with KidsIOT
Previous
HOW to Make an Automatic Lighting System with KidsIOT
Read More
HOW to Make A Fan with Temperature Detection Function by Kidsuno
Next
HOW to Make A Fan with Temperature Detection Function by Kidsuno
Read More
Message Us