Skip to content

Yr 6 1.2.2 Inputs & Event-Driven Programming

Welcome to Year 6 Computing — Micro:bit Lesson 2: Inputs & Events! 🎛️⚡

Last week, our code ran the exact second the micro:bit turned on. Today, we are going to take control! We will use Inputs (like buttons and sensors) to trigger our code using a technique called Event-Driven Programming.

Target Standards:

  • CSTA 1B-AP-10: Create programs that include sequences, events, loops, and conditionals.
  • ISTE 1.5.c: Break problems into component parts, extract key information, and develop descriptive models.
  • UK NC: Design, write and debug programs that control or simulate physical systems.

Step 1: Keyboard Warm-up ⌨️ (10 Mins)

Step 2: What is an Event? 🎬 (5 Mins)

In computing, an Event is an action that the computer is waiting for. For example, “When Button A is pressed” is an event. The computer sits and waits, and as soon as the event happens, it runs the blocks inside it!

Step 3: Micro:bit Classroom – Step-by-Step 🛠️ (10 Mins)

Let’s program our first Input event! Log into your teacher’s Micro:bit Classroom.

  1. Look at the blue menu on the left. Click on the pink Input category.
  2. Click and drag the on button A pressed block onto your workspace. (Notice it is not a loop; it has a flat top!).
  3. Go to the Basic menu and drag a show icon block inside the Button A block.
  4. Change the icon to a Happy Face.
  5. Look at the simulator on the left of your screen. Click the virtual “A” button. What happens?

Step 4: The Advanced Digital Pet Challenge 🐶 (25 Mins)

Mission: Build an Interactive Pet!

You know how to make the micro:bit react to Button A. Now, you must combine Events (from today) with Sequences and Pauses (from last week) to make a realistic digital pet! Experiment, test, and debug it yourself!

  • Rule 1 (Feed): When you press Button A, the pet must show a Happy face, pause for 1 second, and then clear the screen (go back to neutral).
  • Rule 2 (Scold): When you press Button B, the pet must show a Sad face.
  • Rule 3 (Dizzy): When you Shake the micro:bit, the pet must show a Dizzy animation (two icons alternating), then automatically fall Asleep.
  • Rule 4 (Wake Up): Can you figure out how to program the A+B button to wake the pet up with a Surprised face?
  • Bonus: Download your `.hex` file to your real micro:bit and test your pet!

Step 5: End of Lesson Reflection 👋 (10 Mins)

Fill in the reflection tool below to prove your understanding of Inputs and Events. Click download to save your certificate!

Inputs & Events Reflection

Comments are closed, but trackbacks and pingbacks are open.