Tutorpip← About this lessonOpen the sheet →Download PDF
Ages 8+ · Coding · Variables and data
Messages and events
A tap on thebutton (theevent)The messagestart is sentThe helpershear itThe show begins
One tap starts the whole show.
The big ideaAn event, like a tap, can send a message that makes other things happen.

How it works

Something that happens is called an event. A tap, a key press, a click or a timer can be an event.

An event can send a message, and everyone who is listening can act on it.

Each helper listens for the same message. Here the message is start.

One signal starts everyone at once, so nobody has to guess.

The helper• Tavi• Mina• BoDoes this• switches on the lights• plays the music• opens the curtain
When the message start comes.

Example 1: A bell is a signal

  1. At practice, Ms. Okoro holds up a little brass bell.
  2. When the bell rings, the helpers start. The ring is the signal.
  3. Ding! Tavi's lights glow on, right on time.

Example 2: An event sends a message

  1. Tavi makes a start button on a screen.
  2. When the button is tapped, the tap is the event.
  3. The event sends the message start.

Example 3: Listening

  1. Tavi's rule says: when start is heard, switch on the lights.
  2. The message start is sent.
  3. Tavi hears it, so the lights come on.
1when start is heard:2 switch on the lights
A helper listens for the message start.

Example 4: Everyone acts

  1. Mina listens for start too, and so does Bo.
  2. The music begins and the curtain swishes open.
  3. One message reaches all three helpers.

Words to know

event
Something that happens, like a tap.
message
What an event sends, like start.
signal
A message that tells everyone to begin.
listen
To wait for a message so you can act on it.

Watch out

Try it

  1. Is a mouse click an event?
  2. Is a quiet room an event?
  3. A key press starts the music. Which is the event, the press or the music?
  4. Why use one signal for everyone?
Answers: 1. Yes · 2. No · 3. The key press · 4. So everyone starts together
Try at homePick three jobs, like a light, a song and a bow. Agree on one signal, like a clap or a bell. When the grown-up gives the signal, every job begins together. Then try it without a signal and see the muddle.
For grown-upsPlay the Mission: pick three jobs, like a light, a song and a bow, and agree on one signal, like a clap or a bell. When you give the signal, every job begins together. Then try it without a signal and see the muddle.
Open these notes on screenScan the code, or go to tutorpip.com.