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 18th, 2024 545 views
In this experiment, we will apply both LED module and button module to form a lighting device.

Flow

4101

Assembly

line1

Required:

41_00

line1

Step 1

41_01

line1

Step 2

41_02

41_03

line1

Step 3

41_04

line1

Step 4

41_05

line1

Step 5

41_06

line1

Step 6

41_07

line1

Step 7

41_08

line1

Step 8

41_09

line1

Completed!

41_10

line1

Wiring Diagram

4102

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.1Manual_lighting.sb3

4103

Click 3209 to connect to port and then 2210.

Explanation

5top

Code Blocks

Blocks

Code block

Events

begin

P

setmode

P

setout

P

readanalog

Operators

=

Control

forever

Control

ifelse

line5

Conceive:

  1. Initialization

    Set the pins of white LED module and button module, initialize the serial monitor.

    4104

line3

  1. Main Code

    Loop: Determine whether the button is pressed. If it is, the button outputs 0. If not, the button outputs 1.

    • Press the button (pin IO26 reads value 0), and LED will light up (pin IO23 outputs 1 to LED module).

    • Release the button (pin IO26 reads value 1), and LED will go off (pin IO23 outputs 0 to LED module).

    4105

5bottom

Test Result
4top
After uploading code, press the button, and LED lights up. When you release the button, LED is off.
4106
4bottom
HOW to Build a Smart Trash Can (Drop Alarm) with Kidsuno
Previous
HOW to Build a Smart Trash Can (Drop Alarm) with Kidsuno
Read More
How to Program Relay Module on Kidsuno
Next
How to Program Relay Module on Kidsuno
Read More
Message Us