Open KidsBlock and connect the board to your computer. Click File –> Load from your computer.
Choose D:\Code\1.Code_kidsuno to open 4.6Ultraviolet detection.sb3 file.
Click to connect to port and then .
Conceive:
When the UV index is within 0 ~ 2, the ultraviolet light is the weakest, and it does not have much effect on the human body. When the index increases to 3 ~ 4, the ultraviolet light is weak, but remember to wear sunscreen when going out.
Herein, we set the threshold of the UV index to 3. If the value exceeds 3, the red LED will light up to remind you to wear sunscreen. If the value does not reach 3, the LED will go off.
Code structure:
Initialization.
Loop:
if elif statement to determine the range of UV index, and output the value.
Determine whether the UV index exceeds 3.
UV index > 3: the red LED lights up as a reminder.
UV index ≤ 3: the red LED goes off.