Open KidsBlock and connect to the board, click File –> Load from your computer.
Choose D:\Code\2.Code_kidsIOT to open 4.2Automatic_lighting.sb3
Click to connect to the port and then .
Code Blocks
Blocks |
Code block |
---|---|
![less than](media/less than.png) |
|
Conceive:
Initialization
Set the pins of white LED module and the photoresistor; Initialize the serial monitor.
Main Code
Loop:
① Print the value read by the photoresistor.
② Determine whether the photoresistor value is less than 1000 every 0.1s.
value < 1000 (weak light): LED lights up.
value ≥ 1000 (adequate light): LED goes off.