Open KidsBlock and connect the board to computer. Choose File –> Load from your computer.
Choose path D:\Code\1.Code_kidsuno and open 4.2Trigger mode.sb3.
Click to connect to port and then .
Code Blocks
Blocks |
Code block |
---|---|
Build blocks:
Click to add libraries DC Motor and Ultrasonic.
Initialization
Initialize the serial port.
Main Code
Loop: the ultrasonic sensor reads the distance values and the serial monitor prints them. It determines whether the value is less than 10cm(this threshold can be modified).
Distance < 10, fan rotates.
Distance > = 10, fan stops.