X
Home > Blog > STEM for Arduino > HOW to Make a Manual Control Fan with Kidspico

HOW to Make a Manual Control Fan with Kidspico

By r October 28th, 2024 36 views
In this project, we adopt a capacitive touch sensor and an 130 motor to combine a fan in manual mode. We can control the startup of the fan by the capacitive touch sensor.

Flow

4401

Assembly

line1

Required Components

44_00

line1

Step 1

44_01

line1

Step 2

44_02

line1

Step 3

44_03

line1

Step 4

44_04

line1

Step 5

44_05

line1

Step 6

44_06

line1

Step 7

44_07

line1

Completed

44_08

line1

Wiring Diagram

4402

Test Code

Open 4.4Manual mode.py and click 1407.

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

touch = Pin(2, Pin.IN)
INA = Pin(14, Pin.OUT)
INB = Pin(15, Pin.OUT)

press = 0

while True:
    if touch.value() == 1 and press == 0:
        INA.value(0)
        INB.value(1)
        press = 1
    elif touch.value() == 1 and press == 1:
        INA.value(0)
        INB.value(0)
        press = 0
    time.sleep(0.1)

Explanations

5top

Conceive:

  1. Initialization:

    Set pins of the capacitive touch sensor and the 130 motor.

    Define a variable press with an initial value of 0, which is used to control the state of motor.

  2. Loop:

    if touch.value() == 1 and press == 0: 
        INA.value(0)
        INB.value(1)
        press = 1
    

    When the module is touched (touch.value() == 1) and press = 0, the fan rotates and press will be assigned to value 1.

    elif touch.value() == 1 and press == 1:
        INA.value(0)
        INB.value(0)
        press = 0
    

    When the module is touched (touch.value() == 1) and press = 1, the fan stops working and press will be assigned to value 0.

    Point: When we continuously touch the module, we need to know and control the state of the motor through the value of press.

5bottom

Test Result
4top
After uploading code, touch the module and the fan starts to work. Touch it again, and the fan will stop.
4403
4bottom
HOW to Make a Remote Control Fan with Kidspico
Previous
HOW to Make a Remote Control Fan with Kidspico
Read More
HOW to Make a Track Alarm with KidsIOT
Next
HOW to Make a Track Alarm with KidsIOT
Read More
Message Us