Events cause—or trigger—something else to happen in a program.
What do you think is the event in this program?
What does the event cause BOLT to do?
The program in the GIF uses an on collision event block. BOLT detects when it has run into an object (like a foot!) and then it changes its direction and the color of the main LED.
There are lots of event options with BOLT: on collision, on landing, on freefall, on gyro max, on charging, on not charging, and on message received.
Select the new program button in the left sidebar.
Name your program, choose Blocks as your program type, and choose BOLT as your robot.
Scroll to the event category of the library and explore some of the event options with BOLT.
Place a speed block under on start program. Set the speed to 125.
Place a heading block under the speed block. Keep the heading at 0°.
Scroll to the Events category of the block library.
Drag an on collision event off to the side of the on start program block.
What do you want BOLT to do after it has been bumped? Well, in pseudocode—or common language—used to describe coding blocks or commands, you want BOLT to:
stop
change its main LED to a random color
play a beep beep sound
change its heading to the opposite direction (current heading + 180°)
delay for 0.5 seconds to get under control
and restart its speed
Place all of the blocks shown below onto the canvas. Use the block color to help. The color indicates the category of the library that the block comes from. For example, the gray heading block is found in the gray Sensor category.
Connect and assemble the blocks in the correct order to the on collision event block. Use the pseudocode in the previous step to help with the order. HINT: Use the block shape to help you figure out where to put it. For example, the hexagonal random color block fits into the hexagonal input in the main LED block.
This assignment is Pass/Fail and out of 15 points. Upload a video of you and a partner playing is pong game.