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

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.

The missions are built so that the program from the mission before does not pass. A student who is stuck is almost always one line away. Send them to Give me a hint before you show them the answer: the hints come one at a time, and the last one is the line itself.

How to read this guide

Each lesson is a row of short parts, and each part has the same five headings:

  1. Say what to tell the class, in a sentence or two. Use your own words if you like.
  2. Students do the steps, in order. Read them out or put them on the board.
  3. On their screens what you should see when you walk round. If a screen does not look like this, that student needs you.
  4. If it goes wrong what usually goes wrong at this step, and the way out.
  5. 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

LessonMissionsThe one ideaStandards it serves
1. A program that drives1, 2 and 3A program is instructions the mower repeats. A sensor lets it chooseCSTA 2-AP-12, 2-CS-02
2. A mower that remembers4 and 5A variable keeps a value from one tick to the nextCSTA 2-AP-11, 2-AP-12
3. Flowers, a tree and the battery6 and 7A program checks the most important thing firstCSTA 2-AP-12, 2-AP-17
4. Back to work8 and 9A variable can remember a place, and switch the mower between two jobsCSTA 2-AP-11, 2-AP-13, 2-AP-17
5. The right sensor10 and 11The right part depends on what the program asks of itCSTA 2-CS-02, NGSS MS-ETS1-2

Before the first lesson

The screen. These are the names this guide uses, and they are the words on the screen.

NameWhere it isWhat it is for
Missions, Brain, Run, Design, YardAlong the topThe tabs. These lessons use Missions, Brain and Run
The briefThe right side of the Brain tabWhat this mission asks for: the goal, what is new, and Give me a hint
Test in RunTop right of the Brain tabRuns the program on the mission's lawn
The goalsTop right of the Run tabOne line for each goal, with a check mark when it is met
What the brain seesUnder the goalsWhat the mower senses on this tick, and the value of every variable the student made
StepUnder the lawnStops the mower and moves it one tick at a time
Skip to resultUnder the lawnRuns to the end at once, for when watching is not needed
PathUnder the lawnShows or hides the yellow line of where the mower has driven
SensorUnder the lawn, in missions 10 and 11 onlyChooses the mower's positioning sensor. Each choice shows the price of the whole mower

Lesson 1: A program that drives

The one ideaThe 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 endEvery student has a mower that drives down a lane, stops before the edge, turns around and comes home.
New wordsfunction, sensor, if, else, heading
The first winThe mower moves because of a line the student typed. Aim for every student to be there by minute five.
MinutesPart
0 to 10The first program (mission 1)
10 to 25Look before you drive (mission 2)
25 to 40There and back (mission 3)
40 to 45What the mower knows

Lesson 1: The first program (0 to 10)

  1. 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.
  2. 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.
  3. 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%.
  4. 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.
  5. 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)

  1. 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.
  2. 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);.
  3. 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.
  4. 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.
  5. 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)

  1. 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.
  2. Students do Press Next mission. In the program, replace drive(0); with turnTo(270); and press Test in Run.
  3. 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.
  4. 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.
  5. 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 ideaA variable keeps a value from one tick to the next. That is how a mower remembers which way it is going.
By the endEvery student has a mower that fills in a whole lawn by itself.
New wordsvariable, true and false, or
The first winThe mower goes all the way around the lawn, and the student watches the variable change at each corner.
MinutesPart
0 to 20Lap the lawn (mission 4)
20 to 30Watch it think
30 to 45Fill it in (mission 5)

Lesson 2: Lap the lawn (0 to 20)

  1. 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.
  2. 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.
  3. 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%.
  4. 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.
  5. 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)

  1. Say A program does what you wrote, which is not always what you meant. These are the tools for finding the difference.
  2. 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.
  3. 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.
  4. If it goes wrong The mower runs on by itself: Step only steps while the run is stopped. Pressing Step once stops it.
  5. 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)

  1. 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.
  2. 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.
  3. 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%.
  4. 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 ||.
  5. 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 ideaA program can ask several questions, and the order matters. It checks the most important thing first.
By the endEvery 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 wordsobstacle, battery, return
The first winThe mower turns away from the flower bed without touching it.
MinutesPart
0 to 20Flowers and a tree (mission 6)
20 to 40Come home (mission 7)
40 to 45How low is too low

Lesson 3: Flowers and a tree (0 to 20)

  1. 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.
  2. 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().
  3. 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.
  4. 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.
  5. 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)

  1. 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.
  2. 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.
  3. 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.
  4. 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 <.
  5. 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 ideaA variable can hold a place as well as a number. Another variable can switch the mower between two jobs.
By the endEvery 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 wordsposition, null, lanes
The first winAfter its charge the mower drives straight back to the spot it left and carries on.
MinutesPart
0 to 20Back to work (mission 8)
20 to 45Lanes (mission 9)

Lesson 4: Back to work (0 to 20)

  1. 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.
  2. 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.
  3. 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%.
  4. 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);.
  5. 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)

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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 ideaA 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 endEvery 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 wordssensor, drift, cost
The first winThe cheapest mower mows the lanes lawn as well as the most expensive one.
MinutesPart
0 to 20Pay for what you need (mission 10)
20 to 35When it has to be exact (mission 11)
35 to 45The table

Lesson 5: Pay for what you need (0 to 20)

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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)

  1. 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.
  2. 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.
  3. 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%.
  4. 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.
  5. 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

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

Mission 2: Stop at the edge

Mission 3: There and back

Mission 4: Lap the lawn

Mission 5: Fill it in

Mission 6: Flowers and a tree

Mission 7: Come home

Mission 8: Back to work

Mission 9: Lanes

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.