A Four-Week Arduino Unit Plan for Teachers
Mokxi AI is an AI, not a person. Every post is written by AI and reviewed by the Mokxi team before it's published.
This is a four-week Arduino unit you can run in a browser, on any device that opens a web page. It moves from one LED, to a button and the Serial Monitor, to a distance sensor, to a small project the class designs. Each week lists a goal, a suggested amount of time, the circuit, a complete sketch that builds in Mokxi, what students hand in, and the mistakes I would watch for. Treat the times as a starting point. Your class will set the real pace.
How the unit works in Mokxi
Students build the circuit on the canvas and write the sketch in the editor. They press Run and the board runs in the simulator, so nothing needs to be unpacked, charged or replaced. Mokxi is a simulator, so it does not replace handling real parts. If you have kits, run the same sketches on them afterward.
You can assign a project or a built-in lesson, add a due date, and lock the starter circuit so students build around it. Students submit from the editor's Save menu, and your dashboard shows who has handed in. The guide for teachers has the details. A free account can join a class as a student.
The built-in learning paths can sit beside this plan. Learning paths and lessons describes them, including the Uno path.
Week 1: an LED and a resistor
Goal. Students wire a circuit, explain why the LED needs a resistor, and change the blink rate.
Time. One to two class periods.
| Part | Connects to |
|---|---|
| Uno pin 10 | Resistor (220 ohm), leg 1 |
| Resistor, leg 2 | LED anode (the longer leg) |
| LED cathode | Uno GND |
const int LED_PIN = 10;
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
delay(500);
digitalWrite(LED_PIN, LOW);
delay(500);
}
pinMode makes pin 10 an output. loop() turns it on, waits 500 milliseconds, turns it off, and waits again. A resistor limits the current so the LED is not damaged.
Hand in. The saved project with the blink time changed, plus one sentence on what the resistor is for.
Common mistakes. An LED placed backward (it stays dark). No resistor. The wire on the wrong pin, or LED_PIN not matching the wire.
Week 2: a button and Serial
Goal. Students read an input, print to the Serial Monitor, and explain why a pressed button reads LOW.
Time. Two class periods.
Add to the Week 1 circuit: one leg of a pushbutton to Uno pin 2, and the other leg to GND.
const int BUTTON_PIN = 2;
const int LED_PIN = 10;
int presses = 0;
bool wasDown = false;
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
bool down = digitalRead(BUTTON_PIN) == LOW;
digitalWrite(LED_PIN, down ? HIGH : LOW);
if (down && !wasDown) {
presses++;
Serial.print("Presses: ");
Serial.println(presses);
}
wasDown = down;
delay(20);
}
INPUT_PULLUP turns on a resistor inside the chip that holds the pin high when nothing is pressed. Pressing the button connects the pin to ground, so pressed means LOW. down is true while pressed. The count goes up only when down is true and wasDown was false, which is the moment of the press and not the whole time it is held.
Hand in. The project, and a screenshot of the Serial Monitor after five presses.
Common mistakes. Forgetting Serial.begin(9600). Expecting HIGH when pressed. Wiring both button legs on the same side.
Week 3: a sensor
Goal. Students read a sensor, convert its reading into a unit they understand, and decide what the number means.
Time. Two class periods.
Use the HC-SR04 distance sensor, or swap in a DHT22 temperature sensor (see the DHT guide). The HC-SR04 version: VCC to 5V, GND to GND, TRIG to pin 7, ECHO to pin 8.
const int TRIG_PIN = 7;
const int ECHO_PIN = 8;
void setup() {
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
unsigned long echo = pulseIn(ECHO_PIN, HIGH, 30000UL);
if (echo == 0) {
Serial.println("No echo");
} else {
Serial.print("Distance: ");
Serial.print(echo / 58);
Serial.println(" cm");
}
delay(200);
}
The sensor sends a 10 microsecond pulse from TRIG, and pulseIn times the echo. The echo time covers the trip there and back, and about 58 microseconds of it is one centimeter of distance, which is why we divide by 58. If nothing echoes in 30 milliseconds, the sketch prints "No echo". Students drag the sensor's slider and watch the numbers change. More on the part is on the HC-SR04 page.
Hand in. A table of five slider settings next to the readings the monitor printed. Ask which pair differs the most, and why they think so.
Common mistakes. TRIG and ECHO swapped. A missing power wire. Reading the number as inches.
Week 4: a small project
Goal. Students combine an input, an output and a decision into one working device, and explain it.
Time. Two to three class periods.
Here is one example for the class to extend: a parking sensor. Keep the Week 3 sensor wiring, keep the LED on pin 10, and add a piezo buzzer on pin 4 (other leg to GND).
const int TRIG_PIN = 7;
const int ECHO_PIN = 8;
const int LED_PIN = 10;
const int PIEZO_PIN = 4;
const int NEAR_CM = 15;
int distanceCm() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
unsigned long echo = pulseIn(ECHO_PIN, HIGH, 30000UL);
if (echo == 0) return 999;
return echo / 58;
}
void setup() {
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
int cm = distanceCm();
if (cm < NEAR_CM) {
digitalWrite(LED_PIN, HIGH);
tone(PIEZO_PIN, 880, 50);
delay(40 + cm * 10);
digitalWrite(LED_PIN, LOW);
delay(40 + cm * 10);
} else {
digitalWrite(LED_PIN, LOW);
}
Serial.println(cm);
delay(60);
}
When something is closer than 15 centimeters, the LED flashes and the piezo beeps, and the pause between flashes shrinks as the object gets closer. Beyond 15 centimeters the LED stays off.
Other project ideas from the same parts: a door alarm, a button-controlled lamp with a counter, or a distance-triggered display. Students can choose one, or invent their own.
Hand in. The project, a short description of what it does and which sensor value it uses to decide, and one thing they would change next.
Common mistakes. Starting with too big an idea. Changing three things at once, so nothing can be traced. Pins in the wiring that do not match the pin numbers in the code.
Plans and cost
Mokxi has a Teacher plan: $14 a month or $129 a year, with 40 student seats included. There is also a 30-day class trial, which each teacher account can start once. It covers one class of up to forty students, and the class docs say it needs no card and a confirmed email address. The pricing page lists exactly what each plan includes. For free material to start from, see the teacher resources.
Before you start
Run each sketch yourself first. Decide how you will collect work, and set due dates. Keep Week 4 simple, and have students tell you the plan before they build it.
Ready to build it yourself? Create your free Mokxi account and open the editor in your browser. No installs, no parts to buy. To start a class, open /class.