A classic physical computing project that brings hardware to life. The robot drives forward until its "eyes" detect a wall, at which point it stops, looks around, and turns to a clear path.
Components: Arduino board, motor driver H-bridge board (e.g., L298N or DRV8833), two DC motors, HC-SR04 ultrasonic sensor, robot chassis, servo, external battery pack.
The Build: The ultrasonic sensor acts as the input, pinging soundwaves to calculate distance. The Arduino processes this distance and sends signals to the motor driver to control the direction and speed of the wheels.
Learning Outcome: You will learn how to manage power distribution (separating motor power from the Arduino logic board) and write conditional if/else logic to govern autonomous movement.
This is a framework for a hands-on physical computing workshop. Structuring this around project-based learning ensures that every new line of code or wired component immediately serves the larger goal of building a functional, autonomous robot.
Using the Arduino Nano alongside the DRV8833 is an excellent hardware choice for beginners—it keeps the chassis compact and operates much more efficiently at lower voltages compared to older drivers like the L298N.
Here is a comprehensive 5-session workshop outline (15 hours total) designed to steadily build complexity while preventing cognitive overload.
Goal: Demystify the hardware, introduce the Arduino IDE, and establish foundational programming concepts (setup, loop, variables, and basic I/O).
Hour 1: Ecosystem & First Upload
Introduction to the Arduino Nano: What is a microcontroller vs. a computer?
Navigating the Arduino IDE: Selecting the board, COM ports, and the structure of a sketch (setup() vs loop()).
Activity: The "Blink" sketch. Modifying delay times to create heartbeat patterns.
Hour 2: Breadboarding & Digital Outputs
How breadboards work (rails vs. rows).
Basic electronics safety: Why we need current-limiting resistors for LEDs.
Activity: Wiring an external LED. Writing code to blink the external LED.
Activity: Practice in cutting, stripping, and soldering wires.
Hour 3: Serial Communication & Digital Inputs
Wiring a tactile button (pull-up/pull-down resistor concepts, or using INPUT_PULLUP).
Introduction to the Serial Monitor for debugging.
Activity: Pressing a button to turn on an LED, and printing the button state to the Serial Monitor.
Pro-Tip for Instructors: Teach students early to format their Serial output cleanly (e.g., Serial.println(sensorValue); rather than wrapping outputs in unnecessary quotation marks) to make reading rapid data streams easier.
Goal: Understand H-bridges, wire the motor driver safely, and write functions to control chassis movement.
Hour 1: Power Management & The DRV8833
Understanding the separation of logic power (USB/Nano) and motor power (battery pack).
How an H-bridge works to reverse motor polarity.
Activity: Wiring the DRV8833. Connecting the battery pack, the Nano's digital pins to the driver's IN pins, and the driver's OUT pins to the two DC motors.
Hour 2: Basic Directional Control
Writing digital HIGH/LOW states to the DRV8833 to drive motors forward, backward, and stop.
Activity: Writing a hard-coded sequence—drive forward for 2 seconds, stop, reverse for 2 seconds, spin left.
Hour 3: Speed Control & Custom Functions
Introduction to Pulse Width Modulation (PWM). Using analogWrite() to control motor speed.
Introduction to modular code: Writing custom moveForward(speed) and stopMotors() functions to clean up the loop().
Activity: Calibrating the motors. (DC motors rarely spin at the exact same speed; students will use PWM to adjust left/right bias so the robot drives straight).
Goal: Introduce the ultrasonic sensor for distance measurement and the servo motor for panning the sensor.
Hour 1: The HC-SR04 Ultrasonic Sensor
How sonar works (Trigger pulse and Echo timing).
Using the pulseIn() function and the math to convert microsecond travel time into centimeters or inches.
Activity: Wiring the HC-SR04 and printing distance measurements cleanly to the Serial Monitor.
Hour 2: The Micro Servo
How servos differ from DC motors (positional control vs. continuous rotation).
Including libraries in Arduino (#include <Servo.h>).
Activity: Wiring the servo and writing a program to sweep it from 0 to 180 degrees.
Hour 3: Assembly & The "Look Around" Routine
Mechanically mounting the ultrasonic sensor to the servo horn, and attaching the assembly to the front of the robot chassis.
Activity: Writing a function that sweeps the servo to 30°, 90°, and 150°, taking a distance reading at each stop, and printing those three values.
Goal: Merge the motion code with the sensor code to create basic autonomous obstacle avoidance.
Hour 1: Code Merging & State Machines
Strategies for combining complex sketches. Moving from linear delays to basic state logic (e.g., "If path is clear, drive forward. Else, stop and check surroundings").
Activity: Merging the DRV8833 motor functions with the HC-SR04 reading functions.
Hour 2: Basic Obstacle Avoidance
Writing the primary logic loop.
Activity: Programming the robot to drive forward indefinitely until an object is detected within 15cm, at which point it calls the stopMotors() function.
Hour 3: The "Look and Decide" Algorithm
Implementing decision-making logic using if/else statements.
Activity: When an obstacle is detected, the robot stops. The servo looks left, then right. The Arduino compares the two distance variables, determines which side has more open space, turns the chassis in that direction, and resumes driving.
Goal: Refine the autonomous behavior, troubleshoot real-world physics issues, and celebrate the completed projects.
Hour 1: Tackling Real-World Physics & Edge Cases
Addressing the limitations of ultrasonic sensors (e.g., angled walls deflecting sound waves, soft materials absorbing sound).
Replacing blocking code (delay()) with non-blocking timers (millis()) if students are ready for the challenge, allowing the robot to read sensors while driving rather than stopping to look.
Hour 2: Track Testing & Iteration
Setting up an arena or obstacle course.
Activity: Iterative testing. Students observe their robots in the arena, identify failure points (e.g., turning too far, ignoring narrow table legs), and refine their speed variables and trigger distances.
Hour 3: Workshop Showcase & Next Steps
Students demonstrate their robots navigating the course.
Code walkthroughs: Have students explain one custom function they are proud of.
Wrap-up: Discussing what sensors could be added next (line-tracking IR sensors, Bluetooth modules for remote control).
Costs for Robot Project
Arduino Nano. $15.99 for 3 $5.33
Half-size Breadboard. $6.88 for 6 $1.14
DRV8833 H-Bridge. $12.99 for 10 $1.29
6V ‘AA’ Battery Pack w/Switch. $6.99 for 4 $1.74
AA Batteries(4) $1.52
LM 2596 Buck Converter $1.29
or AMS-1117 5V ($0.45)
TT Yellow Motors with Wheels. $15.99 for 8. $4.00
Casters $7.84 for 10 $0.78
HC-SR04 Ultrasonic Sensor. $9.99 for 5 $2.00
SG-90 Microservomotor $18.99 for 10. $1.89
Solid Hook-up Wire, various colors
Foamcore board
Velcro
Total: $22 per robot