Open KidsBlock and connect the board to computer. Choose File –> Load from your computer.
Choose path D:\Code\1.Code_kidsuno and open 4.1Temperature detection.sb3.
Click to connect to port and then
.
Code Blocks
Blocks |
Code block |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Build blocks:
Click to add libraries 18b20 and DC Motor.
Initialization
Initialize the serial monitor.
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.