Bit Board Coding: Buttons, Loops, and Lights

← Free Lesson Plans for Teachers

Free Lesson Plan

Grade 5Engineering & Coding2 sessions x 50 minmicro:bitBit Board1B-AP-101B-AP-15

⬇ Download PDF (lesson, student sheets & answer key)

Driving question: How can we write a program that reacts when someone presses a button?

Overview

Students connect two contrasting jumbo LEDs and a jumbo pushbutton to a micro:bit through a Bit Board expansion board and program them with block code (Microsoft MakeCode). They build up from a sequence (light on, wait, off) to a loop (blink forever), then an event (on button A pressed), and finally a conditional reading an external Bit Board pushbutton on Pin 4 (if digital read pin P4 = 0, show Go light; else Stop light).

Each step includes a planted bug for students to find and fix. Teams finish by designing a "crosswalk signal" program.

Standards

CodeStandard
CSTA 1B-AP-10 (2017)programs with events, loops, and decisions
CSTA 1B-AP-15 (2017)testing and fixing a program

CSTA K-12 CS Standards (2017), Level 1B (grades 3-5). This lesson has not been reviewed or endorsed by CSTA.

Learning Objectives

Students will:

  • create programs that use sequences, loops, events, and conditionals.
  • test and debug programs so they run as intended.
  • design a crosswalk signal program that responds to a button.

Materials

Geyer resources for this lesson

  • Bit Board Kit
    1 per pair (12 sets for a class of 24): expansion board, 4 jumbo 10 mm LEDs, 2 jumbo pushbuttons, piezo speaker, Maker Tape, and guide cards (micro:bit sold separately).
  • Bit Board Classroom Set 1 Pack
    Classroom packaging option for groups of 2-3 students.

Also needed

  • micro:bit boards with USB cables (1 per pair; required, not included in Bit Board Kit)
  • Computers or tablets with MakeCode (makecode.microbit.org; 1 per pair)
  • Student Sheets 1 and 2 (1 each per student)

Vocabulary

WordWhat it means
sequenceSteps that run in order.
loopCode that repeats.
eventSomething that happens (like pressing built-in button A) that starts code.
conditionalAn if/then (else) choice in code.
bugA mistake in a program.
debugTo find and fix mistakes.
pinA connection point on the micro:bit and Bit Board for parts.

Safety Notes

  • Bit Board kits contain small parts and are labeled as not intended for children under 10; supervise Grade 5 students and count parts back in.
  • Unplug USB and batteries before moving LEDs or buttons.
  • Handle boards by the edges; keep drinks away from electronics.

Before You Teach

  • Install the Bit Board on one micro:bit and test a blink program (LED + to Pin 1, white - to GND).
  • Pick two contrasting jumbo LEDs from your kit (such as red and green, or label LED 1 as Stop on Pin 1 and LED 2 as Go on Pin 2). Wire the Bit Board pushbutton between Pin 4 and GND (white; pushbuttons have no polarity).
  • Note for MakeCode: the "on pin pressed" event block only exists for touch on P0/P1/P2/logo, so an external Bit Board pushbutton on Pin 4 uses "set pull pin P4 to up" in "on start" and "digital read pin P4 = 0" inside "forever" (pressing pulls P4 to GND = 0).
  • Prepare the four "buggy" programs from Student Sheet 1 as shared links or screenshots.

Warm-Up (5 min)

  • Act it out: one student is the "computer" and follows commands: "Clap. Wait. Clap." Then "Repeat forever." Then "When I raise my hand, jump."
  • Name the ideas: sequence, loop, event.

Procedure

Sequence and loop (20 min)

  1. Connect LED 1 (+ to Pin 1, white - to GND). Program: digital write pin P1 to 1, pause 500 ms, digital write pin P1 to 0, pause 500 ms, inside a forever loop.
  2. Fix Bug 1 on Student Sheet 1.

Events (25 min)

  1. Use MakeCode's built-in "on button A pressed" event block to turn LED 1 on, pause 1000 ms, and turn it off. (Teacher note: "on pin pressed" only works for touch on P0, P1, P2, or the V2 logo; next session we will read an external Bit Board pushbutton with digital read.)
  2. Fix Bug 2.

Conditionals (25 min, Session 2)

  1. Connect LED 2 (+ to Pin 2, - to GND) and a Bit Board jumbo pushbutton between Pin 4 and GND (no polarity).
  2. In "on start", add "set pull pin P4 to up" (keeps P4 at 1 when unpressed). Inside "forever", use if/else: if digital read pin P4 = 0 (pressed, pulled to GND), set Go LED (P2) to 1 and Stop LED (P1) to 0; else set Stop LED (P1) to 1 and Go LED (P2) to 0.
  3. Fix Bugs 3 and 4.

Crosswalk challenge (25 min)

  1. Design a program: Stop LED stays on until the Bit Board button is pressed (digital read pin P4 = 0); then Go LED turns on for 5 seconds with speaker beeps, then back to Stop LED.
  2. Test with three test cases (Student Sheet 2) and record results.

Differentiation

SupportOn-levelChallenge
• Start from a partly built program.
• Use only the micro:bit built-in buttons A and B before adding the Bit Board button.
• Pair programming with clear driver/navigator roles.
• Complete the procedure and student sheets as written.• Add a countdown on the LED matrix.
• Use a variable to count button presses.
• Add a potentiometer to change the blink speed.

Assessment

  • Can students name the sequence, loop, event, and conditional in their code?
  • Do they predict before running?
  • Do debug notes name the bug and the fix?

Exit ticket: "Explain the difference between an event and a conditional. Give an example of each."

CriterionBeginningDevelopingProficient
Uses constructsSequence onlySequence and loopSequence, loop, event, and conditional
DebuggingCannot find bugsFinds bugs with helpFinds and fixes bugs and explains them
Crosswalk programDoes not runRuns, misses a test casePasses all test cases

Extensions

  • Program a reaction-time game.
  • Add the piezo speaker for an accessible audio signal.
  • Grade 6: code a Bit Board Rover.

Student Sheets

Use these sheets in class, or download the PDF for a print-ready layout.

Student Sheet 1

Bug Hunt

Print-ready version in the PDF.

Name: ______________________________   Date: ______________

BugWhat the code doesWhat it should doThe fix
1LED turns on once and never blinksBlink forever
2Pressing button A does nothingLED turns on when button A is pressed
3Go LED is always on (even when Bit Board button is not pressed)Go LED only when button on P4 is pressed
4Both LEDs on at the same timeOnly one LED on at a time

Which construct (sequence, loop, event, conditional) did each fix involve?

Student Sheet 2

Crosswalk Signal Design and Tests

Print-ready version in the PDF.

Name: ______________________________   Date: ______________

Plan your program (pseudocode or sketch of blocks).
Test caseExpectedActualPass?
No button press for 10 sStop LED stays on
Press button onceGo LED 5 s with beeps, then Stop
Press button during GoGo keeps going, then Stop
Show answer key (for teachers)

Answer Key & Teacher Notes

Bug Hunt

  • Bug 1: the blink code is in "on start" instead of "forever"; also needs a pause after turning off. Construct: loop.
  • Bug 2: the event block uses button B instead of button A (or writes to the wrong LED pin). Construct: event.
  • Bug 3: missing "set pull pin P4 to up" in "on start", or checking digital read = 1 instead of 0 (a pressed Bit Board button pulls P4 to GND = 0). Construct: conditional.
  • Bug 4: the program never writes 0 to the other LED. Construct: sequence/conditional.

Exit ticket

An event starts code when something happens (on button A pressed). A conditional checks a condition while code runs in a loop and chooses what to do (if digital read pin P4 = 0 then ... else ...).

Need a print-ready copy? The PDF includes the lesson, student sheets, and answer key.

Download the PDF  |  All free lesson plans

Free for classroom use. You may print and copy this lesson for your students. © Geyer Instructional Products. Standards text: CSTA K-12 CS Standards © CSTA.