LawnBot teaching notes
For teachers, co-op leaders and parents. Five lessons of about forty-five minutes, for ages eleven and up. Each part says what to say, what students do, what their screens should show, what usually goes wrong, and a question to ask. You do not need to be able to program to use them: the finished program for every mission is at the end.
Using this with a class? Make a free class and add your students yourself: each gets a username and password, with no email or Google account needed. Or give them one join code. Using Google Classroom? Post the link there; with a free class, the link also puts each student in your class, so you see their work.A first lesson: Everyone starts mission 1, where one line of code makes the mower drive down a lane, and works up to mission 5, where the same mower fills in a whole lawn. Then the class compares programs: who needed the fewest lines, and why does turning when the grass ahead is already cut finish the lawn?
Set up a free class Share to Google Classroom- About these lessons
- How to read this guide
- The five lessons
- Before the first lesson
- Lesson 1: A program that drives
- Lesson 1: The first program (0 to 10)
- Lesson 1: Look before you drive (10 to 25)
- Lesson 1: There and back (25 to 40)
- Lesson 1: What the mower knows (40 to 45)
- Lesson 2: A mower that remembers
- Lesson 2: Lap the lawn (0 to 20)
- Lesson 2: Watch it think (20 to 30)
- Lesson 2: Fill it in (30 to 45)
- Lesson 3: Flowers, a tree and the battery
- Lesson 3: Flowers and a tree (0 to 20)
- Lesson 3: Come home (20 to 40)
- Lesson 3: How low is too low (40 to 45)
- Lesson 4: Back to work
- Lesson 4: Back to work (0 to 20)
- Lesson 4: Lanes (20 to 45)
- Lesson 5: The right sensor
- Lesson 5: Pay for what you need (0 to 20)
- Lesson 5: When it has to be exact (20 to 35)
- Lesson 5: The table (35 to 45)
- For students who finish early
- The finished program for each mission
- Where to go next
About these lessons
Five lessons of about forty-five minutes each, for ages eleven and up. Students write the program a robot lawn mower follows. There are eleven missions. Each one is a small lawn and a goal, and each one needs one new idea. A lesson covers two or three missions.
You do not need to be able to program to teach these. Everything you are asked to say or point at is written here, in the words that are on the screen, and the finished program for every mission is at the end of this page. Every mission has been walked through in the app with real clicks, and is checked again whenever the app changes.
How to read this guide
Each lesson is a row of short parts, and each part has the same five headings:
- Say what to tell the class, in a sentence or two. Use your own words if you like.
- Students do the steps, in order. Read them out or put them on the board.
- On their screens what you should see when you walk round. If a screen does not look like this, that student needs you.
- If it goes wrong what usually goes wrong at this step, and the way out.
- Ask a question for the room. The point is the talking, so take two or three answers and do not give yours.
The five lessons
| Lesson | Missions | The one idea | Standards it serves |
|---|---|---|---|
| 1. A program that drives | 1, 2 and 3 | A program is instructions the mower repeats. A sensor lets it choose | CSTA 2-AP-12, 2-CS-02 |
| 2. A mower that remembers | 4 and 5 | A variable keeps a value from one tick to the next | CSTA 2-AP-11, 2-AP-12 |
| 3. Flowers, a tree and the battery | 6 and 7 | A program checks the most important thing first | CSTA 2-AP-12, 2-AP-17 |
| 4. Back to work | 8 and 9 | A variable can remember a place, and switch the mower between two jobs | CSTA 2-AP-11, 2-AP-13, 2-AP-17 |
| 5. The right sensor | 10 and 11 | The right part depends on what the program asks of it | CSTA 2-CS-02, NGSS MS-ETS1-2 |
Before the first lesson
- Every student needs LawnBot open in a browser, with a keyboard. It runs on a Chromebook. Nothing is installed.
- With an account, press Save on the page now and then. The program for every mission is kept in the project, and so is which missions are done.
- The program can be written two ways. Code is JavaScript in a text box. Blocks builds the same program from blocks. These notes show code. A class that uses blocks does the same steps with the block that has the same words.
- Try missions 1 to 3 yourself first. They take ten minutes, and you will have met every button the class will meet in lesson 1.
The screen. These are the names this guide uses, and they are the words on the screen.
| Name | Where it is | What it is for |
|---|---|---|
| Missions, Brain, Run, Design, Yard | Along the top | The tabs. These lessons use Missions, Brain and Run |
| The brief | The right side of the Brain tab | What this mission asks for: the goal, what is new, and Give me a hint |
| Test in Run | Top right of the Brain tab | Runs the program on the mission's lawn |
| The goals | Top right of the Run tab | One line for each goal, with a check mark when it is met |
| What the brain sees | Under the goals | What the mower senses on this tick, and the value of every variable the student made |
| Step | Under the lawn | Stops the mower and moves it one tick at a time |
| Skip to result | Under the lawn | Runs to the end at once, for when watching is not needed |
| Path | Under the lawn | Shows or hides the yellow line of where the mower has driven |
| Sensor | Under the lawn, in missions 10 and 11 only | Chooses the mower's positioning sensor. Each choice shows the price of the whole mower |
Lesson 1: A program that drives
| The one idea | The mower runs the student's function about ten times a second. Whatever is inside it is what the mower does. A sensor answers a question, and if and else choose what to do with the answer. |
| By the end | Every student has a mower that drives down a lane, stops before the edge, turns around and comes home. |
| New words | function, sensor, if, else, heading |
| The first win | The mower moves because of a line the student typed. Aim for every student to be there by minute five. |
| Minutes | Part |
|---|---|
| 0 to 10 | The first program (mission 1) |
| 10 to 25 | Look before you drive (mission 2) |
| 25 to 40 | There and back (mission 3) |
| 40 to 45 | What the mower knows |
Lesson 1: The first program (0 to 10)
- Say This is LawnBot. A robot mower does only what its program tells it, and today you write that program. The mower runs your code about ten times every second.
- Students do Open LawnBot and press Start mission 1. Read the brief on the right. Press Test in Run before you change anything, and see what happens. Then press Back to the Brain, type drive(1); on the empty line inside the curly braces, and press Test in Run again.
- On their screens The first time, the mower stays on its blue dock and a card says Not yet, with 5% beside Mow at least 90% of the lane. The second time the mower drives down the lane, the grass behind it turns bright green, a yellow line follows it, and the card says Mission complete with 93%.
- If it goes wrong A red line under the code says The mower does not know "Drive": capital letters matter, and it must be drive. The line says A { is never closed: a curly brace was deleted, and Start over puts the starting code back. The mower does not move and there is no red line: the new line is outside the curly braces.
- Ask You typed drive(1) once. Why did the mower keep driving the whole way down the lane?
Lesson 1: Look before you drive (10 to 25)
- Say Watch the end of the lane. The mower kept pushing against the end of the lawn. A real mower would wear itself out. It needs to look before it drives.
- Students do Press Next mission. This is the same lane with one more goal: Never bump into anything. Press Test in Run first and read the goals. Then change the program so it asks edgeAhead(): when that is true, drive(0); and when it is not, drive(1);.
- On their screens With the old program the goals show 51 bumps and the card says Not yet. With the new one the mower stops just short of the end of the lane, and the card says Mission complete with 0 bumps. In What the brain sees, the line ahead changes from clear to edge just before it stops.
- If it goes wrong The mower never moves: edgeAhead was typed without its brackets, and then the if is always true. It must be edgeAhead(). The mower never moves and the brackets are there: the two branches are the wrong way round.
- Ask The mower stopped before it touched the edge. How did it know the edge was there?
Lesson 1: There and back (25 to 40)
- Say A mower that stops at the far end has to be carried home. Make it turn around and come back. The mower uses compass headings in degrees: 0 is east, 90 is south, 180 is west and 270 is north. It starts facing south.
- Students do Press Next mission. In the program, replace drive(0); with turnTo(270); and press Test in Run.
- On their screens The mower drives to the end, turns on the spot until it faces north, drives back and stops beside its dock. The third goal, Finish back where it started, says at the dock. In the panel, heading() goes from 90 to 270 while it turns.
- If it goes wrong It stops at the far end and the third goal says not there: the number in turnTo is not 270. With 180 the mower faces a side of the lane, where the edge is still ahead, so it never drives again.
- Ask At the top of the lane the edge is ahead again. Why does the mower not turn around a second time?
Lesson 1: What the mower knows (40 to 45)
Finish with the class looking at one screen. Open mission 3 in Run, press Mow, then press Step a few times and read What the brain sees aloud. On every tick the mower knows only what is on that list. Ask what it does not know: where the lawn ends until the edge is just ahead, how long the lane is, or that it has been here before. Every mission from here on gives it one more thing to know.
Lesson 2: A mower that remembers
| The one idea | A variable keeps a value from one tick to the next. That is how a mower remembers which way it is going. |
| By the end | Every student has a mower that fills in a whole lawn by itself. |
| New words | variable, true and false, or |
| The first win | The mower goes all the way around the lawn, and the student watches the variable change at each corner. |
| Minutes | Part |
|---|---|
| 0 to 20 | Lap the lawn (mission 4) |
| 20 to 30 | Watch it think |
| 30 to 45 | Fill it in (mission 5) |
Lesson 2: Lap the lawn (0 to 20)
- Say Today the lawn is a whole rectangle. To go around it the mower has to turn left at every corner: south, east, north, west. It has to remember which way it is going, and a variable does that.
- Students do Open mission 4 from the Missions tab. The program starts with var facing = 90; above the function. Inside the braces of if (turnTo(facing)), write an if and an else: when edgeAhead() is true, facing = facing - 90; and when it is not, drive(1);. Press Test in Run.
- On their screens The mower drives down the left side, turns, and goes around the outside of the lawn. In the panel, under Your variables, facing reads 90, then 0, then -90, then -180. The card says Mission complete with 45%.
- If it goes wrong The mower gets stuck at the first corner. There are two usual causes. var facing = 90; was moved inside mowerTick(), so it goes back to 90 on every tick: it belongs above the function. Or the new lines are below the braces of if (turnTo(facing)) when they belong inside them.
- Ask The mower turned at four corners, but your program only has one line that changes facing. How does one line make four turns?
Lesson 2: Watch it think (20 to 30)
- Say A program does what you wrote, which is not always what you meant. These are the tools for finding the difference.
- Students do In Run, press Reset, then Mow. As the mower nears the first corner press Step, and keep pressing it. Watch ahead, heading() and facing in the panel. Then press Top to look straight down, and press Path to hide and show the yellow line.
- On their screens Each press of Step moves tick up by one. At the corner, ahead becomes edge, then facing drops from 90 to 0, then heading() falls about ten degrees a tick until it reaches 0, and only then does the mower drive again.
- If it goes wrong The mower runs on by itself: Step only steps while the run is stopped. Pressing Step once stops it.
- Ask For about nine ticks at the corner the mower did not move. What was it doing, and which line of your program made it wait?
Lesson 2: Fill it in (30 to 45)
- Say One lap leaves the middle uncut, and the mower keeps going around the same path forever. It has a sensor for grass that is already cut. Two straight lines between words mean or.
- Students do Press Next mission. Only one line needs to change. Make the mower turn when the edge is ahead or the grass ahead is already cut: if (edgeAhead() || cutAhead()). Press Test in Run.
- On their screens The mower goes around the outside, and when it comes back to grass it has already cut it turns early. Each lap is smaller than the last, and the path is a square spiral into the middle. The card says Mission complete with 98%.
- If it goes wrong The mower drives into the edge and the goals count bumps: the two conditions are joined with &&, which means and. At the first corner the edge is ahead but the grass is not cut, so and is false. It must be ||.
- Ask You changed one line and the mower went from 45% of the lawn to 98%. What does the mower know now that it did not know before?
Lesson 3: Flowers, a tree and the battery
| The one idea | A program can ask several questions, and the order matters. It checks the most important thing first. |
| By the end | Every student has a mower that leaves a flower bed alone, goes around a tree and gets home to charge before its battery is empty. |
| New words | obstacle, battery, return |
| The first win | The mower turns away from the flower bed without touching it. |
| Minutes | Part |
|---|---|
| 0 to 20 | Flowers and a tree (mission 6) |
| 20 to 40 | Come home (mission 7) |
| 40 to 45 | How low is too low |
Lesson 3: Flowers and a tree (0 to 20)
- Say This lawn has a flower bed and a tree in the middle. The mower can drive straight over a flower bed and never feel a bump, so the program has to look for it.
- Students do Open mission 6. Press Test in Run first and watch what last lesson's program does. Then add two more sensors to the same line, each joined with ||: flowersAhead() and obstacleAhead().
- On their screens With the old program the mower drives across the flower bed and into the tree: the goals show 8 mowed and 51 bumps. With the new one it spirals in, turns away from the bed and the tree, and the card says Mission complete with 86%, 0 bumps and untouched. A band of grass around the bed and the tree stays uncut.
- If it goes wrong A red line says The mower does not know "flowersahead": the A is a capital. The goals still count bumps: obstacleAhead() is missing from the line.
- Ask The mower left a strip of grass around the flower bed. Is that a mistake in your program, or is it the mower being careful? What would a person do about that strip?
Lesson 3: Come home (20 to 40)
- Say This mower has a small battery, too small to finish this lawn on one charge. A mower that runs out on the grass is stuck there. The program has to check the battery before it decides anything else.
- Students do Press Next mission. Press Test in Run first and watch the battery. Then, at the top of mowerTick(), add: if (battery() < 30) {, then goToDock();, then return;, then }. Press Test in Run again.
- On their screens The first time, the battery bar falls to zero, the word at the top of the panel changes to Out of battery, and the first goal says ran out. The second time, when the battery reaches 30% the word changes to Heading home, the mower drives to the dock, charges, and the goal says charged. The card says Mission complete with 60%. After charging the mower turns on the spot beside the dock and the run ends.
- If it goes wrong A red line says A { is never closed: the new if is missing its closing brace. The mower goes home at once and never mows: the sign is the wrong way round, > in place of <.
- Ask After it charged, the mower turned in circles at the dock and did nothing. Look at the lawn from the Top. Why could it not find any grass to cut?
Lesson 3: How low is too low (40 to 45)
A short experiment for the whole room. Half the class changes 30 to 5, the other half changes it to 50, and everyone presses Test in Run then Skip to result. Going home at 5% the mower has cut 82% of the lawn when it finishes; at 50% it has cut 43%. Ask which number a real mower should use, and what could go wrong with 5 on a bigger lawn, a hill, or an old battery.
Lesson 4: Back to work
| The one idea | A variable can hold a place as well as a number. Another variable can switch the mower between two jobs. |
| By the end | Every student has a mower that goes back to where it stopped after a charge and finishes the lawn, and a second program that mows in lanes. |
| New words | position, null, lanes |
| The first win | After its charge the mower drives straight back to the spot it left and carries on. |
| Minutes | Part |
|---|---|
| 0 to 20 | Back to work (mission 8) |
| 20 to 45 | Lanes (mission 9) |
Lesson 4: Back to work (0 to 20)
- Say Last lesson the mower charged and then turned in circles, because everything near the dock was already cut. Today it remembers where it was, and goes back there.
- Students do Open mission 8. The program has two numbered comments. At 1, add spot = position();. At 2, add if (turnTo(headingTo(spot))) {, then drive(1);, then }. Press Test in Run.
- On their screens The mower mows until the battery reaches 30%, goes home and charges. Then it drives in a straight line back to the place it left, with its blade off, and carries on with the spiral. Under Your variables, spot shows an x and a y while the mower travels and null once it arrives. The card says Mission complete with 99%.
- If it goes wrong The mower charges and then turns in circles as before: step 1 is missing, so spot is still null. The mower charges, turns toward the spot and never leaves the dock: step 2 turns the mower but has no drive(1);.
- Ask The mower drove back with its blade off. What would the lawn look like if the blade were on for that trip, and why would that confuse cutAhead()?
Lesson 4: Lanes (20 to 45)
- Say This lawn has a shed against one edge, and the spiral gets stuck beside it. Lanes do not: drive to the end, move over, come back the other way. The mower knows how far it is from the left side of the yard, in meters: that is position().x.
- Students do Press Next mission. The program has two numbered comments. At 2, three lines: nextX = position().x + 0.5; then facing = 360 - facing; then moving = true;. At 1, an if and an else: when position().x >= nextX, moving = false; and otherwise face east with turnTo(0), drive, and return;. The third hint shows the whole of step 1. Press Test in Run.
- On their screens The mower drives south, moves half a meter east, drives north, and so on across the lawn, turning back early where the shed is. The path is a row of long thin loops. The card says Mission complete with 95%. A small patch beside the shed stays uncut.
- If it goes wrong The mower runs into the shed or the east edge while it moves over: the check for edgeAhead() || obstacleAhead() inside step 1 is missing, and the third hint has it. Stripes of uncut grass between the lanes: the lanes are too far apart. With 0.6 in place of 0.5 the mower finishes at 88% and the card says Not yet.
- Ask The spiral and the lanes both cut a whole lawn. Which would you choose for a lawn with a tree in the middle, and which for a long thin lawn? Why?
Lesson 5: The right sensor
| The one idea | A positioning sensor that drifts is good enough for a short move and no good for finding a place again. The right sensor depends on what the program asks of it. |
| By the end | Every student has found the cheapest mower that mows the lanes lawn, the cheapest that gets back to its spot, and can say why they are not the same mower. |
| New words | sensor, drift, cost |
| The first win | The cheapest mower mows the lanes lawn as well as the most expensive one. |
| Minutes | Part |
|---|---|
| 0 to 20 | Pay for what you need (mission 10) |
| 20 to 35 | When it has to be exact (mission 11) |
| 35 to 45 | The table |
Lesson 5: Pay for what you need (0 to 20)
- Say So far the mower has always had GPS, which tells it exactly where it is. GPS is the most expensive part of a mower. The cheaper sensors only estimate the position, and the estimate drifts: it gets a little more wrong with every meter the mower drives, until the mower docks again. Today you find out when that matters.
- Students do Open mission 10. It is the lawn from Lanes with your own lanes program. Press Test in Run, then Skip to result, and read the goals. Then find the Sensor list under the lawn, pick a cheaper sensor, and press Skip to result again. Before each run, say whether you expect the lanes to line up.
- On their screens With GPS-RTK the mower mows about 95% of the lawn and the card says Not yet: the goal Build cost $1,000 or less shows $1,535. Wheel odometry is $1,185 and Perimeter wire is $1,025, both still too much. With Bump only, $955, the lanes line up just as before and the card says Mission complete.
- If it goes wrong The editor shows a line that says to finish mission 9 first: this mission uses the student's own program from Lanes, so that one has to be done. The lanes drift apart on a cheap sensor: that student's program uses position() to find a place far away. It should only use it for the half meter to the next lane, as the last hint says.
- Ask position() is wrong on the cheap sensor, and the lanes still lined up. What does this program use position() for, and why does a small error not matter there?
Lesson 5: When it has to be exact (20 to 35)
- Say Now the program from Back to work: the mower remembers the spot where it stopped, goes home to charge, and drives back to the spot. This time it starts with the cheapest sensor.
- Students do Press Next mission. Press Test in Run and watch what the mower does after it charges. Then try each sensor in the Sensor list. For each one, write down its price and the distance beside the goal Start mowing again within 0.15 m of where it stopped.
- On their screens With the three cheaper sensors the mower drives away from the dock toward the wrong place. The goal shows a distance such as 1.17 m away, or not back yet when it never gets there, and the card says Not yet. With GPS-RTK the mower goes straight back to its spot, the goal shows about 0.03 m away, and the card says Mission complete with 99%.
- If it goes wrong A student's distances do not match their neighbor's: that is expected. The drift depends on the exact path the mower drove, so the numbers differ from program to program. The cheaper sensors never come within 0.15 m. The editor shows a line that says to finish mission 8 first: this mission uses the student's own program from Back to work.
- Ask The same cheap sensor was good enough for lanes and not good enough here. What is this program asking position() to do that the lanes program never asked?
Lesson 5: The table (35 to 45)
Put one table on the board and fill it in from the room: the four sensors down the side, and across the top the price, whether the lanes lawn was mowed, and how far from its spot the mower came back. Then ask the engineering question: a customer has a long thin lawn and a mower with a small battery. Which sensor do you fit, and what would you want to know first? There is no single right answer. A student who says it depends on what the program has to do has understood the lesson.
For students who finish early
- Switch the same mission to Blocks and read the program as blocks. Change one block and run it.
- Add say("turning"); where the mower changes facing, and watch the words appear beside the lawn.
- In mission 9, try lanes of 0.25, 0.4 and 0.6 of a meter. Which is fastest and still passes?
- Open Free mow on the Missions tab. Build a mower in Design, pick a starter yard in Yard, and run the mission 9 program on it. In Run, Pattern can be set to Stripes, a built-in program: how close does yours get to it?
The finished program for each mission
One program that passes each mission. There is more than one right answer: the app judges what the mower did, not how the code is written. These are the programs the app's own tests run.
Mission 1: First cut
- function mowerTick() {
- drive(1);
- }
Mission 2: Stop at the edge
- function mowerTick() {
- if (edgeAhead()) {
- drive(0);
- } else {
- drive(1);
- }
- }
Mission 3: There and back
- function mowerTick() {
- if (edgeAhead()) {
- turnTo(270);
- } else {
- drive(1);
- }
- }
Mission 4: Lap the lawn
- var facing = 90;
- function mowerTick() {
- if (turnTo(facing)) {
- if (edgeAhead()) {
- facing = facing - 90;
- } else {
- drive(1);
- }
- }
- }
Mission 5: Fill it in
- var facing = 90;
- function mowerTick() {
- if (turnTo(facing)) {
- if (edgeAhead() || cutAhead()) {
- facing = facing - 90;
- } else {
- drive(1);
- }
- }
- }
Mission 6: Flowers and a tree
- var facing = 90;
- function mowerTick() {
- if (turnTo(facing)) {
- if (edgeAhead() || cutAhead() || flowersAhead() || obstacleAhead()) {
- facing = facing - 90;
- } else {
- drive(1);
- }
- }
- }
Mission 7: Come home
- var facing = 90;
- function mowerTick() {
- if (battery() < 30) {
- goToDock();
- return;
- }
- if (turnTo(facing)) {
- if (edgeAhead() || cutAhead()) {
- facing = facing - 90;
- } else {
- drive(1);
- }
- }
- }
Mission 8: Back to work
- var facing = 90;
- var spot = null;
- function mowerTick() {
- if (battery() < 30) {
- spot = position();
- goToDock();
- return;
- }
- if (spot != null) {
- if (distanceTo(spot) < 0.05) {
- spot = null;
- } else {
- setBlade(false);
- if (turnTo(headingTo(spot))) {
- drive(1);
- }
- return;
- }
- }
- if (turnTo(facing)) {
- if (edgeAhead() || cutAhead()) {
- facing = facing - 90;
- } else {
- drive(1);
- }
- }
- }
Mission 9: Lanes
- var facing = 90;
- var nextX = 0;
- var moving = false;
- function mowerTick() {
- if (moving) {
- if (position().x >= nextX) {
- moving = false;
- } else {
- if (turnTo(0)) {
- if (edgeAhead() || obstacleAhead()) {
- moving = false;
- } else {
- drive(1);
- }
- }
- return;
- }
- }
- if (turnTo(facing)) {
- if (edgeAhead() || obstacleAhead()) {
- nextX = position().x + 0.5;
- facing = 360 - facing;
- moving = true;
- } else {
- drive(1);
- }
- }
- }
Mission 10: Pay for what you need uses the mission 9 program as it is. In Run, set Sensor to Bump only.
Mission 11: When it has to be exact uses the mission 8 program as it is. In Run, set Sensor to GPS-RTK.
Where to go next
After the missions comes Free mow, on the Missions tab. The student builds a mower in Design, where every part has a price and a budget, paints a yard in Yard or traces one from a photo, and runs their own program on it. Starter yards with a tree or a flower bed at the edge are much harder than the mission lawns, and a program that mows 90% of one is a real piece of work. The page of runs under Runs keeps every result, so a student can change one thing and see whether it helped.
More help
Is something on this page wrong or not clear? Write to us.
Page last reviewed October 2026.