Case 5 -Read the value of light intensity

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.

cba16caa-4578-427b-ad0f-9f9a248df0cd.gif

 

Part 2 Preparation

  • mBot x1
  • USB cable x1
  • Computer with network access
  1. Use a data cable to connect the mBot to the computer.

413873a4-416d-4eef-a4a9-866f966c8eea__1_.gif

  1. 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".

af5fe0c3-e8c8-43aa-b957-fa5eb369f47a.gif

 

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.

e76baa0e-7bd2-4219-88e6-8c0fbcac9404.gif

Source program diagram

266e7fbb-9b24-4f9b-ac2e-29fb81ab543e.png

 

Part 4 Procedure source code

get light intensity value.mblock

 

Part 5 Practice

  1. Increase the time value in the Waiting Block to slow down the change in the light sensor value and make user see more clearly.
  1. Ask Panda to describe the real-time intensity of light detected by the current light sensor.

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.