X
Home > Blog > STEM for Arduino > HOW to Make an Automatic Lighting System with Kidspico

HOW to Make an Automatic Lighting System with Kidspico

By r September 26th, 2024 89 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 4.1Manual_lighting.py and click1407.

'''
 * Filename    : Manual_lighting
 * Thonny      : Thonny 4.1.4
 * Auther      : http//www.keyestudio.com
'''
from machine import Pin
import time

led = Pin(11, Pin.OUT)
button = Pin(3, Pin.IN)

while True:
    if button.value() == 0:  #press button
        led.on()     # led on
    else:
        led.off()    # led off

Explanation

5top

Conceive:

  1. Initialization: Set pins of white LED module and button module

  2. Loop:

    Determine whether the button is pressed. If it is, LED will light up. If not, LED will go off.

5bottom

Test Result

4top

After uploading code, press the button, and LED lights up. When you release the button, LED is off.

4103

4bottom

HOW to Build a Smart Trash Can (Drop Alarm) with KidsIOT
Previous
HOW to Build a Smart Trash Can (Drop Alarm) with KidsIOT
Read More
Comprehension! HOW to Monitor Smart Home Environment with ESP32
Next
Comprehension! HOW to Monitor Smart Home Environment with ESP32
Read More
Message Us