Skip to content

Events

The yellow hat blocks in the Events category decide when a stack of blocks starts running. No hat block, no execution.

Common hat blocks

when program starts
when [left] button [pressed]
when hub [shaken]
when <condition>
when I receive [message1]
HatFires when
when program startsThe moment you hit run / start the slot - the most used
when button pressedHub left/right button, great for manual debug triggers
when shakenHub detects a shake/tap
when <condition>The condition flips from false to true (e.g. sensor crosses a threshold)
when I receiveA broadcast [message] block sent this message

Parallel stacks

One project can hold multiple hat blocks, each running independently and simultaneously:

when program starts
set movement motors [A+E]
move [forward] for [5] rotations

when program starts            ← second stack, runs at the same time
forever
  display image [HEART]
  wait [0.5] seconds
  turn off pixels
  wait [0.5] seconds

The robot drives while the light blinks - the simplest form of concurrency.

Don't fight over one motor

Two stacks commanding the same motor produce unpredictable results. Give each parallel stack its own resources: one owns the drive base, another owns lights/attachments.

Broadcasts: signals between stacks

when program starts
move [forward] for [3] rotations
broadcast [arrived]

when I receive [arrived]
run motor [C] [clockwise] for [180] degrees

Broadcasts chain stacks together: when the base arrives, tell the arm to move. In complex competition programs, staging with broadcasts is clearer than one giant stack.

FLL usage

  • Debugging: hang "attachment to zero" under "when left button pressed" - one press at the table resets the arm.
  • Starting: competition rules require hand starts; use program slots + center button, no extra events needed.
  • Multi-mission programs: one slot per launch (run), not event-based switching.

Exercises

  1. Write two parallel stacks: one keeps a motor spinning, the other cycles light patterns every second.
  2. Use a broadcast: drive 2 rotations → broadcast → the receiving stack shows a checkmark.

Next lesson: Loops & Conditions.