Part 1 Objective
User writes a program to display the real-time readings of the on-board light sensor on the mBlock stage area when changing the ambient light around the light sensor.
Part 2 Preparation
-
mBot x1
-
USB cable x1
-
Computer with network access
-
Use a data cable to connect the mBot to the computer.
-
Open MBlock5 (PC, Web, APP), click "Add" in the lower left device area, select mBot in the device library, and click “Connect”.(Live mode: you can click the building block to observe the real-time running effect, but you need to keep the data cable connected to the computer; Upload mode: You can upload the program to mBot, at which time you can unplug the data cable to run the program. ), this course needs to switch to "Live mode".
Part 3 Programming
Create a new variable and name it Light Intensity to store the detected light intensity value and select it to display in real time on the stage area.
Source program diagram
Part 4 Procedure source code
get light intensity value.mblock
Part 5 Practice
-
Increase the time value in the Waiting Block to slow down the change in the light sensor value and make user see more clearly.
-
Ask Panda to describe the real-time intensity of light detected by the current light sensor.
Comments
Please sign in to leave a comment.