Case 2- Random color lights flash

Part 1 Objective

The user writes the program and uploads it to mBot so that mBot can turn on the light randomly.

5456adba-d1eb-4386-9194-d3e09e3cc12f.png

 

Part 2 Preparation

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

c6298adb-9667-4ac1-b4e1-6e98fa0e75d6.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 "Upload mode".

54ed34ea-6665-4666-8589-dbf020743806.gif

 

Part 3 Programming

After the user uploads the program to mBot, the on-board LED lights up randomly to create a colorful effect.

5c90364c-c6c3-49ba-8bd8-d4ef9be615fe.gif

 

Part 4 Procedure source code

Course 2_Random light colours.mblock

 

Part 5 Practice

  1. Modify the start and end values in random numbers
  1. Modify the time value in the Waiting Block

 

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

Comments

0 comments

Please sign in to leave a comment.