Source: https://mokxi.com/learn/robotics-lesson-plans

Learn

# Robotics lesson plans that run in the browser, no kits needed

Intermediate

Written by the Mokxi team

Start building free Open the editor

Or see every lesson.

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

The Obstacle-avoiding car example: an L298N, a two-wheel chassis and an HC-SR04. Drag the sonar slider to put a wall in front of it.

A robotics unit usually starts with a purchase: kits, batteries, spare motors, and a cart to keep them on. This page is a unit that starts without one. Every robot below runs in Mokxi in the browser, with real Arduino code on a simulated Uno, motor drivers and sensors wired on the canvas, and a chassis that drives on the screen. Students can build, code and debug a robot on a Chromebook, and the kits, if you have them, come in later for the last mile.

The circuit above is the centerpiece of the unit, an obstacle-avoiding car: a two-wheel chassis, an L298N motor driver and an HC-SR04 sonar. It drives forward, and when something comes within 250 mm it stops, backs up, turns and carries on. Press Run and drag the sonar’s slider to put a wall in front of it.

## How the unit is laid out

Six lessons, each about one class period, plus a project. Each lesson has a working circuit to open, a short concept, and one change for students to make. The order follows how a robot is built: first make a motor move, then make it move on purpose, then let a sensor decide.

It suits middle school as an introduction, with the teacher driving the code changes, and high school as a full unit, with students writing the decision logic themselves. Engineering, physics and computer science classes can all use it; the standards notes at the end say where it fits.

## Lesson 1: a motor and a driver

Open the robot car drive circuit: two gearbox motors on an L298N module from six Uno pins. It runs forward, turns, spins on the spot and reverses. The concept is why a motor needs a driver at all: an Uno pin can give a few tens of milliamps, a motor wants hundreds, and the driver is a set of switches the pin controls. The change: make the car drive a square.

## Lesson 2: speed with PWM

Stay on the same circuit. The ENA and ENB pins take a PWM signal, and analogWrite(pin, 0 to 255) sets each side’s speed. The concept is duty cycle: the motor sees full voltage in short bursts, and the fraction of time it is on sets the speed. The change: make a gentle curve by running one side slower than the other, then find the values that make the car drive straight.

## Lesson 3: a sensor that measures distance

Introduce the HC-SR04 on its own. It sends a burst of ultrasound and times the echo; the distance is half the round trip at the speed of sound. A reading of 0 in the car’s sketch means no echo at all, nothing in range, not something touching the sensor. The change: print the distance once a second and compare it with where the slider is.

## Lesson 4: sense, decide, act

Now the obstacle car at the top of the page. Its loop is the pattern behind every robot: read the sensor, decide, drive. Clear ahead, drive forward. Closer than 250 mm, stop, back up for 400 ms, spin right for 450 ms, look again. The sketch pings every 60 ms because the sensor needs quiet between pings for the last echo to die away. The change: make it turn left instead, or turn away from whichever side is clearer if you add a second sonar.

## Lesson 5: following a line

Open the line follower: a five-channel line sensor, a TB6612FNG driver and two motors. The sketch works out where the line is under the sensor bar and steers to keep it in the middle, with a proportional and a derivative term. This is the lesson where students meet feedback control without the word: steer harder the further off the line you are. The change: alter the gains and watch the cart wobble or wander.

## Lesson 6: a robot that balances

For a high school class, finish with the self-balancing robot: an MPU6050 measures the tilt, a complementary filter cleans it up, and a PID loop drives the wheels to stay upright. Three knobs set the three gains, so students can feel what each term does. Set Ki or Kd to zero and the robot falls; that is the lesson.

## The project, and the arm

For the final project, give each team a goal rather than a circuit: a car that parks itself, a bumper car that escapes a maze, a line follower that stops at a finish bar. Students start from one of the robots above and change it. For a class that wants something other than wheels, the pick and place arm drives four servos from a PCA9685 board, and the challenge is sequencing moves.

In Mokxi you can hand out a starter, watch each student’s work, run the same checks on every submission and export a gradebook. None of that is needed to use this page; every circuit opens and runs without an account.

## What the simulator does not replace

A robot on a screen does not slip on a dusty floor, run its batteries flat, or catch a loose wire on a wheel. Those are real lessons too, and if you have kits, the last week belongs to them. The point of starting in the browser is that every student gets a working robot and as many tries as they need, and the code they write is the code they upload to a real Uno.

Mokxi is not affiliated with any robotics competition or kit maker, and the unit names no curriculum’s numbering. Where it fits standards: NGSS engineering design (MS-ETS1 and HS-ETS1), and CSTA standards on algorithms and control, are the usual matches, and the standards page lists the codes and says plainly what is not covered.

## Questions

Can I teach robotics without buying robot kits?

Yes, for most of a unit. Students can build, code and test motors, sensors and decision logic in a browser simulator, then use kits, if you have them, for the last week. Every robot on this page runs in Mokxi for free.

What should a high school robotics curriculum cover?

Motors and drivers, PWM speed control, distance and line sensors, the sense, decide, act loop, feedback control (proportional, then PID) and a design project. The six lessons on this page follow that order.

Does it work on school Chromebooks?

Yes. It runs in Chrome with nothing to install, and the simulation runs on the Chromebook itself. Students can open and run a circuit without an account; saving work and joining a class need one.

Is the code the same as on a real robot?

Yes. The sketches are ordinary Arduino C++ for an Uno, and the libraries are the ones from the Arduino Library Manager, so the code uploads to a real board with the same wiring.

Related

## Keep going

Arduino Obstacle Avoiding Robot: Code and Wiring Arduino Line Follower Robot: Code and Circuit Arduino Self-Balancing Robot: MPU6050 and PID Code Arduino L298N Motor Driver: Wiring, Jumpers and Code Arduino PCA9685 Servo Driver: Wiring and Code STEM Club Ideas: Electronics and Coding Sessions Mokxi for teachers The standards map High school engineering Middle school STEM The project page, with the full sketch Intermediate

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
