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.
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.
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.
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.
- Go to code.legoeducation.com and type the lesson PIN. PIN 1302
- 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.
- The palette on the side holds the blocks. Drag a block into the workspace to use it.
- Blocks snap together top to bottom. The program runs in that order, which is the same sequence idea from yesterday.
- Play runs your program. Stop stops everything. Stop is your best friend.
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.
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.
Chemistry
A titration is an event you wait for: when the indicator changes color, then stop adding. A color event in your code is the same idea.
IPC
An air bag is an event: when the car's sensor feels a sudden change in speed, then the bag fires. That is the momentum and impulse lesson, running on code.
LEGO lesson 2 · Basics · Robot Food Service
The robot server is broken. Find out why.
- Build. Model C102, booklet C1, page 16: the robot server, the color scanner and the color bars. Split the steps by minifigure color.
- Predict before you code. Look at the starter code on the screen. Which block is the event? Will both events work with the color bars you built? Write your prediction down.
- Connect and press Play. Open PIN 1302, connect the hardware, press Play, and show each color bar to the sensor.
- Debug. One event never fires. Change it so it matches a color you actually have.
- Make it yours. With your partner, add more events and build another table so the robot can serve more of the restaurant.
Predict first
The starter code has two events. Your color bars are not every color in the world.
Write in your notebook: Event 1 will / will not work because ______. Event 2 will / will not work because ______.
Predict
Hold a color bar up to the sensor:
Starter code
Stuck? Where is the bug?
The second event is listening for blue, and you do not have a blue bar. That event can never happen. Change its color to one you do have. That is debugging: the code was fine, the event just did not match the real world.
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.
Rover: two events
Level up: add a third color that turns the rover.
Arm: two events
Level up: make the arm land on the same spot five times in a row.
Spinner: two events
Level up: a third color that stops it.
Sorter: two events
Level up: what should happen with a color you did not plan for?
Walker: two events
Level up: make it turn by running one side faster.
Your idea: two events
Fill the blanks in your notebook before you touch a block.
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.
Exit ticket
Before you shut the laptop.
- Finish the sentence for one event in your program: When ______, then ______.
- What was the bug in the starter code, and how did you fix it?
- Why do event blocks sit at the top of a stack?
- Physics: your robot runs forward for 2 seconds. What would you measure to find its speed?Chemistry: name one color change in chemistry that you would want a robot to watch for.IPC: two robots push on the same box from opposite sides. What decides which way the box moves?
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.