Brothers LearningFREE LESSONS FOR EVERY CLASSROOM
Brothers Learningany school district
Day 2 of 3 · Thursday, October 1

Sense · Move · Code

Open the Coding Canvas. Now you decide.

Yesterday the robot already knew what every color meant. Today you take that decision away from it and write it yourself. You will connect your kit to the computer, find a bug in some starter code, fix it, and then program the robot you designed yesterday.

Group sizeFour, one computer
Opencode.legoeducation.com
LEGO lessonBasics 02 · Robot Food Service
when color is …run motorwaitstop motorcolor bars = events waiting to happen

Absent today? Read this page and work the simulator in section 04 until both events fire. Then see me. You will get ten minutes with a kit and a computer to connect your hardware and run one event before Friday's lab.

0–4 minYesterday in one minute
4–10Tour the Coding Canvas
10–14What is an event?
14–24Build the robot server
24–34Predict, connect, debug
34–46Program your own robot
46–50Save, sort, charge
01

Yesterday in one minute

Input in. Output out. Something in the middle decides.

Input

The color sensor saw a color.

The middle

Yesterday the hardware had its own built-in rules. Today the middle is your code.

Output

The motor moved.

02

The Coding Canvas

Five things to find on the screen.

Coding Canvas runs in the web browser. There are no student accounts and no passwords. Each lesson has a PIN that opens the starter code and the blocks you need for that lesson.

PIN 1302 Hardware when color isrun motorstop motorwaitlight when color is RED run motor forward wait 1 second stop motor when color is BLUE run motor backward 1 2 3 4 5 1 The lesson PIN2 Connect your hardware3 Block palette4 Your program5 Play / Stop Sketch for teaching. Your screenwill look a little different.
  1. Go to code.legoeducation.com and type the lesson PIN. PIN 1302
  2. Connect your hardware. Power on the color sensor and the double motors. Coding Canvas walks you through connecting them. When they show up as connected, you are ready.
  3. The palette on the side holds the blocks. Drag a block into the workspace to use it.
  4. Blocks snap together top to bottom. The program runs in that order, which is the same sequence idea from yesterday.
  5. Play runs your program. Stop stops everything. Stop is your best friend.
03

New idea · Events

An event is something that happens that your program is waiting for.

You already live by events. When the bell rings, you go to your next class. When your phone buzzes, you look at it. The bell and the buzz are events. What you do next is the response.

Say it this way

When ______, then ______.

When the sensor sees red, then the motor runs forward. Every event in your program should fit that sentence.

Find it on the screen

Event blocks have a rounded top, like a hat. Nothing can snap above them, because nothing comes before an event. They sit at the top and wait.

when color is red
run motor
Events in your class:

Physics

A photogate timer in a physics lab is an event machine: when the beam is broken, then start the clock. Tomorrow your robot does something very close to that.

05

Your robot, your way

Program the robot you designed yesterday.

Rebuild or keep improving your own design. Your goal: at least two events that make it do two different things. Plan it in plain words first. Writing the plan in plain words before you code is called pseudocode, and it saves a lot of time.

When the code does not do what you meant

  • Read the program out loud from the top, one block at a time.
  • Check the event: is it waiting for something that can actually happen?
  • Check the hardware: is it on, charged and connected?
  • Change one thing, then test again. Change three things at once and you will never know which one fixed it.
06

Exit ticket

Before you shut the laptop.

  1. Finish the sentence for one event in your program: When ______, then ______.
  2. What was the bug in the starter code, and how did you fix it?
  3. Why do event blocks sit at the top of a stack?
  4. Physics: your robot runs forward for 2 seconds. What would you measure to find its speed?
Teacher notes · Day 2

LEGO material: Teacher Portal → CS & AI 6–8 → Basics → 02 Robot Food Service (C102). Building instructions C1, page 16. Coding Canvas PIN 1302. Uses the double motors and color sensors, and one computer per group of four.

The intended bug: one of the two when color detected hat blocks in the starter code is set to a color that is not on the students' color bars, so that event never triggers. Students fix it by changing the hat block's color.

Before class: check that every laptop reaches code.legoeducation.com and that the hardware firmware is current (Teacher Portal → Support → Update Firmware). Charge everything again.

The simulator in section 04 mirrors the lesson's bug so absent students can practice the reasoning without a kit. Block wording on this page is simplified; the real palette wording differs a little.

Standards. Science and engineering practices (strand 1) in P.1, C.1, IPC.1: use appropriate tools and develop and use models. CSTA grades 6–8: 2-AP-10 use flowcharts and/or pseudocode to address problems as algorithms; 2-AP-17 systematically test and refine programs; 2-CS-03 systematically identify and fix problems with computing devices.

Next class · Friday

Your robot, your lab: code it, run it, measure it.

Friday is a real lab in your own course, using the robot you built.

Day 3 →