Robotic Lawn Mowers: Boundary, Blades and Balance
A mower robot spends its life on a flat, featureless surface with no map and no satellite indoors, so it has to answer one question over and over: where does the grass stop? Boundary sensing is the whole job.
How a mower knows where the lawn ends
Older commercial mowers run a thin insulated wire around the lawn, and the mower carries a pair of coils that detect the signal in that wire. Drive the coil toward the wire and the signal strength rises, so the mower can follow it and then turn away. Newer battery mowers instead use a camera looking for a boundary strip, an RTK satellite fix, or a radar fence around the property.
The cheapest home build uses the same principle with a different sensor. An ultrasonic sensor pointed down detects a drop in the returned signal when the wheels leave the grass and reach a hard surface, because the beam reflects weakly from soil and strongly from a path or a patio. The catch is that it has to look down at the ground rather than along it, and the threshold has to be set for your own grass height.
Why grass is hard on the electronics
A blade motor under load is the single biggest power draw on the machine. Cutting wet grass can pull 2 to 3 A at 12 V on top of two drive motors, and when the supply sags the microcontroller resets, usually with the blade still spinning.
Two mitigations are standard in real machines and in good student builds: give the blade and the drives their own supply, separate from the logic rail, and make the blade stop before the reset happens. A tilt switch or a lift sensor does this in commercial mowers, so that picking the machine up stops the blade at once. Grass also blocks ultrasonic sensing, so a mower that reacts to resistance will stall against a clump rather than see through it.
Step by step
-
Build the drive first
Two geared DC motors with an H-bridge on a chassis with a caster. Confirm the bot drives straight and can turn on the spot before adding anything else.
-
Add the blade and measure the current
Mount a small DC motor with a blade behind a guard. Run it unloaded and note the current, then measure again with the blade just biting into the grass.
-
Separate the supplies
Give the motors their own battery and keep the Arduino on its own regulator. Brownouts during blade startup are the classic fault on this build.
-
Detect the boundary
Mount an ultrasonic sensor pointing down and print the raw distance over grass, over a path and over bare soil. Set the threshold from those numbers rather than from a guess.
-
Add cliff and tilt safety
Wire a tilt switch so the blade stops the instant the machine is lifted. A spinning blade is the one part of this project that can hurt somebody.
-
Add weather and schedule logic
Use a moisture or humidity reading to refuse to cut wet grass, and a timer to send the mower back to its charging dock between sessions.
What you'll need
| Item | Qty | Why |
|---|---|---|
| Arduino Uno R3 | 1 | Enough pins for a dual H bridge, several sensors and a serial log, at a price a school can absorb. |
| 12 V sealed lead acid battery | 1 | A mower runs for hours, and lead acid tolerates the current spikes a blade motor creates. |
| DC gearmotor with wheels | 2 | The traction drive, with enough torque to push through grass that has not been cut for a week. |
| L298N dual H-bridge module | 1 | Two channels, so one module drives both wheels and the blade. |
| HC-SR04 ultrasonic sensor | 1 | Mounted pointing down to detect the drop in reflected signal when the wheels leave the grass. |
| Tilt switch sensor | 1 | Kills the blade if the machine is lifted, which is how commercial mowers make the blade safe. |
Practise it before you build it
Every step above has a matching circuit in the ThinkEdge Learn simulator. The simulator runs a real
Arduino sketch against a modified-nodal-analysis solver, so digitalWrite actually drives the
LED on screen and the readings change when you change the wiring — no hardware, no burnt components.
Mount an HC-SR04 ultrasonic sensor on top of a servo. Sweep the servo from 0° to 180° and back, and at each step measure the distance. Print the results to the Serial Monitor as "angle,distance" pairs. Open the Serial Plotter in the Arduino IDE to see a live radar-like graph of the room. With Processing on your computer, you can build a full visual radar.
A parking sensor beeps faster as you get closer to an obstacle, and stays silent past a safe distance. We use 100 cm as the cutoff: anything closer triggers a beep (faster the nearer you are), anything farther is silent. The trick is to change the `delay()` between beeps based on distance: very close = short delay, close = medium delay, safe = no beep. The green LED above the buzzer lights up at safe distances so the driver has a visual cue that the car can keep moving — sound alone is easy to miss in a noisy parking garage. This is the same "map input range to output range" pattern you used for the potentiometer projects, but applied to time.
An HC-SR04 ultrasonic sensor measures distance by sending out a high-frequency sound pulse (40 kHz, above human hearing) and timing how long it takes to echo back. Sound travels ~343 m/s in air, so distance = (time × speed) / 2 (divide by 2 because the sound travels there AND back). The sensor does the timing for you — you just trigger it and read the echo pulse width.
A real factory counts every box that passes on a conveyor belt using a light sensor or ultrasonic. We are going to build the same logic: an ultrasonic sensor "looks" across a doorway. Whenever something comes within 15 cm (the "very close" 10 cm preset), we increment a counter, flash the green LED, and light up one more tally LED on the row of 5 yellow LEDs (D2, D3, D4, D7, D8) so the kid can SEE how many objects have been counted. The trick is "edge detection" — we only count when the state CHANGES from "no object" to "object", not on every loop while the object is still there.
The Mega has 4 hardware serial ports (Serial, Serial1, Serial2, Serial3). That means you can talk to 4 different devices at the SAME time — like a GPS, a Bluetooth module, an XBee radio, and the USB. Use 3 of those ports to read 3 different sensors in parallel and stream their data to the Serial Monitor as a CSV row every second. This is the foundation of every real Arduino data logger.
Common questions
How much does a robotic lawn mower cost?
Commercial battery mowers run from roughly $300 to more than $1,500 depending on whether they map the lawn or simply follow a boundary wire, and machines with a charging dock sit at the top of that range. A DIY build from an Arduino and parts lands at $80 to $200: $20 to $45 for a chassis with two gearmotors, $6 to $12 for the H-bridge, $4 to $8 for the ultrasonic sensor, and $20 to $45 for the battery and charger.
How do robotic lawn mowers avoid obstacles?
Most of them avoid very little. They follow a boundary and detect that they have hit something with a wheel current or tilt sensor, then reverse and turn away. Only the more expensive models with cameras and satellite positioning build a map and steer around what they see. The obstacle detection version is the easier project, because a bumper switch does most of the work.
Can you build a lawn mower robot with an Arduino?
Yes, and it is a good class project because the hard part is mechanical rather than electrical: getting traction on grass, keeping the blade from tripping the brownout, and setting a boundary threshold that works in sun and in shade. Expect to spend more time adjusting the chassis than writing code.
Related guides
Try the full simulator with your class
103 guided circuit projects, 21 lessons and an in-browser Arduino simulator. The first 15 projects are free, no account needed. NCERT Science mapping on 47 projects, with Arabic and English copy in the regional builds.