Case 5 - Read the light intensity

Part 1 Objective

After you write the program, the stage area of mBlock 5 displays the real-time reading of the on-board light sensor when the ambient light around the light sensor changes.

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

Part 2 Preparation

  • mBot x 1
  • USB cable (Type-B) x 1
  • Computer with network access x 1
  1. Connect mBot to the computer by using the cable.

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

  1. Open mBlock 5 (PC client or web version), click +add in the lower left Devices area, select mBot from the Device Library, click Connect, and select the Live mode. (Live mode: you can click on the blocks to see the real-time running effect, but you need to keep the cable connected to the computer. Upload mode: you can upload a program to mBot, and you can unplug the cable to run the program.)

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

Part 3 Programming

Make a variable and name it "light intensity" to record the light intensities detected by the light sensor and display the light intensities on the stage area of mBlock 5 in real time.

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

Script image

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

Part 4 Project file

5.Read the light intensity.mblock

Part 5 Practice

  1. Add the wait () seconds block from Control blocks to the program to slow down the change in the light intensity, so that you can see the changes more clearly.
  1. Let the sprite Panda say the light intensity detected by the light sensor in real time.

 

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

Comments

0 comments

Please sign in to leave a comment.