X
Home > Blog > STEM for Arduino > HOW to Make A Fan with Temperature Detection Function by Kidsuno

HOW to Make A Fan with Temperature Detection Function by Kidsuno

By r October 10th, 2024 68 views
The fan will monitor the operating temperature. When it is overheat, the fan will start to rotate automatically.

This temperature detection device adopts a DS18B20 temperature sensor and an 130 motor.

Flow

4101

Assembly

line1

Required Components

41_00

line1

Step 1

41_01

line1

Step 2

41_02

line1

Step 3

41_03

line1

Step 4

41_04

line1

Step 5

41_05

line1

Step 6

41_06

line1

Step 7

41_07

line1

Completed

41_08

line1

Wiring Diagram

4102

Test Code

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

3111

Choose path D:\Code\1.Code_kidsuno and open 4.1Temperature detection.sb3.

4103

Click 3209 to connect to port and then 2210.

Explanations

5top

Code Blocks

Blocks

Code block

Events

begin

Vari

variablename

Vari

setvariable

Vari

variable

Serial

serialbegin

Serial

serialprint

Temp

temperature

Operators

greater

Motor

Motor_analogWrite

Control

forever

Control

ifelse

line5

Build blocks:

Click add to add libraries 18b20 and DC Motor.

4105

  1. Initialization

    Initialize the serial monitor.

    4106

line3

  1. Main Code

    Loop: DS18B20 sensor reads the temperature values and the serial monitor prints them. Then, it determines whether the value is greater than 30°C(this threshold is adjustable).

    • Temperature > 30: fan rotates to cool down.

    • Temperature < = 30: fan stops working.

    4107

5bottom

Test Result
4top
After uploading code, the fan will rotate for cooling down when the temperature value exceeds 30°.
You can raise the temperature by pinching the DS18B20 sensor with your finger or lighting a lighter near the sensor.
WARNING: Please use lighters with the guidance of an adult!
4103
4bottom
HOW to Build a Smart Trash Can (Drop Alarm) with Kidspico
Previous
HOW to Build a Smart Trash Can (Drop Alarm) with Kidspico
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