1. Purpose of the Case
Program the CoCube robot to achieve synchronized processes using broadcasting.
2. Materials Used
3. Software Platform
4. Start Programming
In previous lessons, we primarily dealt with sequential structures, where programs execute instructions in a predetermined order. However, in practical applications, we often encounter situations where multiple tasks need to run simultaneously. In such cases, the broadcast feature becomes particularly important. This case will explain how the broadcast feature triggers signals and how to use this mechanism to achieve parallel execution of two program components.
Connect Device: Connect the MicroBlocks IDE to the CoCube robot via a wired or wireless connection.
Find Blocks: Open the "Control" block library and locate the "when received" and "broadcast" blocks. Drag them into the workspace as shown in the image. The broadcast function is implemented through these two blocks.
- Run Program: Using the broadcast feature, you can control the CoCube robot's movement and LED display in parallel. Run the following two programs and experience the difference brought by the broadcast feature.
5. Challenge
You’ve probably encountered a sprinkler truck in real life. When it's working, it sprays water while emitting sounds to alert nearby pedestrians to move away. Let’s try simulating the operation of a sprinkler truck.
Reference Example Program: MicroBlocks——CoCube Case 06 Sprinkler Truck