Open KidsBlock and connect the board to your computer. Click File –> Load from your computer.
Choose D:\Code\2.Code_kidsIOT to open 4.1Rain detection.sb3 file.
Click to connect to port and then .
Conceive:
Set a threshold of voltage to determine the water volume. When there is too much water, the voltage exceeds the threshold, rain is detected, and the buzzer alarms. The buzzer will stop alarming when the voltage is lower than the threshold.
Code structure:
Initialization. Set the pins of the steam sensor and the passive buzzer, set the voltage value of a single scale, and set the frequency of the passive buzzer.
Loop.
Print the analog value and voltage of the steam sensor.
Determine whether the voltage exceeds 1 (Herein, we set 1 as the threshold, which is adjustable according to needs).
voltage > 1: buzzer alarms.
voltage ≤ 1: buzzer does not emit sounds.