Hero background

Flashlight Logic

STEM • 45 • 25 students • Created with AI following Aligned with Common Core State Standards

Download now

Free PDF · we'll email you a copy

STEM
45
25 students
25 May 2026

Teaching Instructions

This is lesson 10 of 20 in the unit "Microbit Mini-Unit for Year 6". Lesson Title: Introduction to Loops and Conditions Lesson Description: Teach loops and conditional statements in coding. Use MakeCode to create a simple flashlight app. Success Criteria: The app uses loops to maintain brightness. Differentiation: Use a flowchart to help visual learners.

Overview

Today students start coding loops and conditions in MakeCode by building a simple “flashlight” app for a micro:bit. Students will connect logical statements to real app behavior: choosing brightness and then using loops to keep the brightness pattern going.

Learning intentions

  • Students will be able to explain what a loop does in a program.
  • Students will be able to use an if/else condition to choose behavior based on an input.
  • Students will be able to design a short flashlight routine using a loop that maintains brightness.
  • Students will be able to debug a program by checking how conditions control what the loop repeats.

Success criteria

  • I can describe (in my own words) how a loop repeats steps.
  • I can write an if/else condition that changes the flashlight behavior.
  • I can use a loop so the flashlight brightness stays on or follows a pattern without manual restarting.
  • I can test and fix at least one bug in my flashlight program.

Curriculum links

  • Number System — positive and negative quantities and meaning of 0 in real contexts (used today as “brightness level” magnitude with possible “off” at 0).
  • Number System — absolute value as distance from 0, interpreted as magnitude (used when students describe brightness as a magnitude).
  • Number System — interpreting inequalities on a number line (used when students compare sensor/button values to decide “on/off/low/high”).

Lesson structure (45 minutes)

  1. 0–5 min · Hook (App demo + quick talk). Teacher shows a short MakeCode or simulated flashlight effect (steady on, then blinking) and asks: “What parts tell the micro:bit to repeat, and what parts decide what brightness to use?” Students turn-and-talk and share 1 idea.

  2. 5–12 min · Mini lesson: loops + conditions. Teacher models two code ideas on the board:

  • Condition: “If button A is pressed, set brightness to 9; else set to 0.”
  • Loop: “Repeat forever: keep setting brightness and show the pattern.” Students identify which lines are “decision” vs “repeat” and label them on a simple example handout.
  1. 12–20 min · Plan it (flowchart + roles). Teacher gives students a one-page flowchart template (input → condition → brightness output → loop). Students complete the flowchart for their app choice:
  • Option A: Button toggles between OFF (0) and ON (max brightness).
  • Option B: If input is “low,” blink slowly; else blink quickly (still using brightness levels, with 0 as off).
  1. 20–32 min · Build in MakeCode (teacher guided). Teacher circulates while the class follows a baseline build:
  • Start with an if/else using a simple input (button press or accelerometer direction).
  • Add a loop (forever) so the flashlight behavior continues.
  • Set LED brightness/output for each branch (brightness = a numeric magnitude; include “0” for off). Students build their program to match their flowchart, using at least one condition and one loop.
  1. 32–38 min · Debug sprint (test, observe, fix). Teacher asks students to run “3 tests”:
  • Test 1: trigger OFF case
  • Test 2: trigger ON case
  • Test 3: confirm the loop keeps behavior going Students use a “Fix-It Checklist” to change only what is needed (e.g., wrong branch, missing loop, brightness not set to 0 when off).
  1. 38–45 min · Share-out + exit ticket. Teacher selects 3–4 quick demonstrations (focus: “Show me the loop” and “Show me the condition”). Students answer the exit ticket:
  • “Circle the part that repeats.”
  • “Write one sentence: What condition decides what happens?”

Resources

  • MakeCode (micro:bit) devices or computers for 25 students
  • Student flowchart template (printed or digital)
  • Fix-It Checklist (printout)
  • Starter code cards (button/if/else + loop blocks)
  • Headphones optional for quiet testing
  • Projection of target example app
  • Exit ticket slips or digital form
  • Timer for the debug sprint

Assessment

  • Formative checks during build: teacher listens for correct “decision vs repeat” language.
  • Debug sprint: check whether students can identify whether the bug is in the condition or the loop.
  • Exit ticket: students must correctly describe which part repeats and what condition controls behavior.

Differentiation

  • Support: provide sentence starters for flowcharts (“If ___ then brightness is ___.” “Else brightness is ___.”) and a partially completed starter flowchart.
  • Support: offer a “minimum viable” flashlight target (only one condition + forever loop with OFF/ON).
  • Extension: challenge students to add a second condition (e.g., Button A sets brightness, Button B changes pattern speed) while still using a loop.
  • EAL/SEN: allow students to use symbols in the flowchart (OFF/ON, ↑/↓ for brightness) and verify understanding with oral checks before coding.

Create Your Own AI Lesson Plan

Join thousands of teachers using Kuraplan AI to create personalized lesson plans that align with Aligned with Common Core State Standards in minutes, not hours.

AI-powered lesson creation
Curriculum-aligned content
Ready in minutes

Created with Kuraplan AI

Generated using openai/gpt-5.4-nano

🌟 Trusted by 1000+ Schools

Join educators across United States