- Introduction to the Robot Platform
- Lesson Objectives Overview
- Complete Command Reference (Beginner Friendly)
- Detailed Lesson Plans (Lessons 1-16)
- Assessment Guidelines
- Troubleshooting Guide
This robot car is a programmable vehicle that can:
- Move forward, backward, and turn
- Sense obstacles using ultrasonic "sound vision"
- See black lines on the ground
- Grab and move objects with a claw
- Make decisions on its own!
The robot has a "brain" (Arduino microcontroller) that runs your code and controls:
- 2 Motors - Make the wheels spin (forward, backward, or opposite for turning)
- Ultrasonic Sensor - Measures distance to objects (like bat echolocation)
- Line Sensors - Detect black vs white surfaces
- 2 Servo Motors - Move the sensor (like turning your head) and control the claw (like your hand)
- RGB LED - Changes colors for feedback
- Buzzer (optional) - Makes sounds
Goal: Master basic forward and backward movement
- Objectives:
- Set up the Arduino environment
- Learn the basic code structure (setup and loop)
- Make the robot move forward
- Control speed and duration
- Skills: Basic programming, sequential thinking
- Time: 45 minutes
- Objectives:
- Make the robot move backward
- Combine forward and backward movements
- Create movement sequences
- Skills: Sequencing, timing
- Time: 30 minutes
- Objectives:
- Plan multi-step movement sequences
- Navigate to specific positions
- Precision in programming
- Skills: Planning, problem-solving, precision
- Time: 60 minutes
Goal: Master turning and rotation
- Objectives:
- Understand how turning works (motors spinning opposite directions)
- Make the robot turn left and right
- Combine turning with forward movement
- Skills: Spatial reasoning, geometry concepts
- Time: 45 minutes
- Objectives:
- Make precise angle turns
- Create complex shapes (hexagon, octagon)
- Understand angle mathematics
- Skills: Geometry, pattern recognition, mathematical thinking
- Time: 60 minutes
- Objectives:
- Navigate waypoints using turns
- Plan complex movement paths
- Solve navigation problems
- Skills: Path planning, strategic thinking
- Time: 60 minutes
Goal: Use sensors to detect and respond to environment
- Objectives:
- Understand ultrasonic sensor operation
- Measure distances
- Make decisions based on sensor data
- Skills: Conditional logic (if-else), sensor integration
- Time: 45 minutes
- Objectives:
- Control servo motors
- Scan environment in multiple directions
- Find optimal paths
- Skills: Scanning algorithms, decision making
- Time: 45 minutes
Goal: Control servos and combine sensors with movement
- Objectives:
- Control the claw servo
- Pick up and move objects
- Coordinate movement with manipulation
- Skills: Task sequencing, coordination
- Time: 45 minutes
- Objectives:
- Combine sensors and movement
- Create autonomous avoidance behavior
- Implement sense-think-act cycles
- Skills: Autonomous behavior, decision trees
- Time: 60 minutes
Goal: Navigate complex environments
- Objectives:
- Navigate through obstacles autonomously
- Implement reliable navigation algorithms
- Handle multiple obstacles
- Skills: Algorithm development, testing, refinement
- Time: 90 minutes
- Objectives:
- Navigate tight spaces
- Implement stuck detection and recovery
- Optimize navigation strategies
- Skills: Advanced algorithms, debugging, optimization
- Time: 90 minutes
Goal: Follow lines autonomously
- Objectives:
- Understand IR line sensors
- Read and interpret sensor values
- Calibrate sensors for environment
- Skills: Sensor calibration, data interpretation
- Time: 45 minutes
- Objectives:
- Implement line-following algorithm
- Handle curves and intersections
- Create smooth following behavior
- Skills: Control algorithms, parameter tuning
- Time: 90 minutes
Goal: Create complete autonomous systems
- Objectives:
- Combine all skills into autonomous behaviors
- Implement state machines
- Create multi-mode robots
- Skills: System design, integration, state machines
- Time: 120 minutes
- Objectives:
- Design complete autonomous missions
- Implement error handling
- Create sophisticated robot behaviors
- Skills: Project design, testing, presentation
- Time: 120-180 minutes (may span multiple sessions)
What is a command? A command is an instruction you give to the robot. Like telling a friend "walk forward 5 steps", you tell the robot "moveForward(speed, time)".
What are those numbers in parentheses? Those are called "parameters" - they give details about HOW to do the command:
- Speed: How fast (0 = stopped, 255 = maximum)
- Duration: How long in milliseconds (1000 = 1 second)
What it does: Makes the robot drive forward
How it works: Both motors spin forward at the same speed, making the wheels roll ahead
Parameters:
speed: How fast to go (0-255). Think of it like a gas pedal:- 0 = stopped
- 100 = slow/gentle
- 180 = medium/normal
- 255 = maximum speed
duration: How long to move in milliseconds:- 1000 = 1 second
- 2000 = 2 seconds
- 500 = half a second
Example:
car.moveForward(150, 2000); // Move forward at medium speed for 2 secondsWhen to use it:
- Going straight
- Approaching an object
- Following a path
What it does: Makes the robot drive backward (in reverse)
How it works: Both motors spin backward, like a car in reverse gear
Parameters: Same as moveForward
Example:
car.moveBackward(120, 1000); // Back up slowly for 1 secondWhen to use it:
- Backing away from obstacles
- Returning to a previous position
- Parking maneuvers
What it does: Makes the robot spin/turn to the left (counterclockwise)
How it works:
- Right motor spins FORWARD
- Left motor spins BACKWARD
- This makes the robot spin in place to the left
Parameters:
speed: How fast to turn (0-255)duration: How long to turn (longer = bigger turn angle)- ~250ms = 45 degrees (small turn)
- ~500ms = 90 degrees (quarter turn)
- ~1000ms = 180 degrees (turn around)
Example:
car.turnLeft(150, 500); // Turn left 90 degrees at medium speedWhen to use it:
- Changing direction
- Avoiding obstacles on the right
- Making shapes (squares, hexagons, etc.)
What it does: Makes the robot spin/turn to the right (clockwise)
How it works:
- Left motor spins FORWARD
- Right motor spins BACKWARD
- This makes the robot spin in place to the right
Parameters: Same as turnLeft
Example:
car.turnRight(150, 500); // Turn right 90 degreesWhat it does: Makes the robot turn 180 degrees (half circle)
How it works: Automatically turns left for the right amount of time to spin halfway around
Parameters: None (it's automatic!)
Example:
car.turnAround(); // Turn to face the opposite directionWhen to use it:
- Going back the way you came
- Escaping dead ends
- Changing direction completely
What it does: Stops all robot movement immediately
How it works: Cuts power to both motors
Parameters: None
Example:
car.stopMotors(); // Stop right now!When to use it:
- End of a movement sequence
- When obstacle detected
- Emergency stop
- Before changing direction
What it does: Measures how far away the nearest object is in front of the robot
How it works:
- Sends out an ultrasonic sound (too high pitched for humans to hear)
- Listens for the echo bouncing back
- Calculates distance based on how long the echo took
- Returns distance in centimeters
Parameters: None
Returns: A number representing distance in centimeters
- 10 = object is 10cm away (very close!)
- 50 = object is 50cm away (medium distance)
- 100+ = object is far away or not detected
Example:
int distance = car.getDistanceToObstacle(); // Measure distance
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
if(distance < 20) {
Serial.println("Too close! Stopping!");
car.stopMotors();
}When to use it:
- Before moving forward
- To avoid hitting walls
- To find objects
- To stop at the right distance
What it does: Points sensor straight ahead and measures distance
How it works: Moves servo to center position (90°), waits for it to stabilize, then measures distance
Example:
int ahead = car.getCenterDistance(); // Look straight and measureWhat it does: Points sensor to the left and measures distance
How it works: Moves servo to left position (0°), waits, then measures
Example:
int leftDist = car.getLeftDistance(); // Look left and measureWhat it does: Points sensor to the right and measures distance
How it works: Moves servo to right position (180°), waits, then measures
Example:
int rightDist = car.getRightDistance(); // Look right and measureWhen to use all three:
// Scan to find the clearest path
int left = car.getLeftDistance();
int center = car.getCenterDistance();
int right = car.getRightDistance();
if(center > left && center > right) {
Serial.println("Go straight!");
} else if(left > right) {
Serial.println("Turn left!");
} else {
Serial.println("Turn right!");
}What it does: Connects the sensor servo motor to the Arduino
How it works: Sets up communication between Arduino and the servo
Parameters:
pin: Which Arduino pin the servo is connected to (usually 10)
Example:
void setup() {
car.attachSensorServo(10); // Connect servo on pin 10
}When to use it: ONCE in setup() before using any servo commands
What it does: Turns the ultrasonic sensor to look to the left
How it works: Rotates servo to 0 degrees (left position)
Example:
car.lookLeft(); // Turn sensor left
delay(500); // Wait for servo to move
// Now you can measure distance to the leftWhat it does: Turns the ultrasonic sensor to look to the right
How it works: Rotates servo to 180 degrees (right position)
Example:
car.lookRight(); // Turn sensor right
delay(500); // Wait for servo to moveWhat it does: Points the ultrasonic sensor straight ahead
How it works: Rotates servo to 90 degrees (center position)
Example:
car.centerServo(); // Point sensor forwardImportant: Always center the servo when done scanning! This ensures the sensor points forward when the robot moves.
What it does: Connects the claw servo motor to the Arduino
Parameters:
pin: Which Arduino pin the claw is connected to (usually 11)
Example:
void setup() {
car.attachClaw(11); // Connect claw on pin 11
}What it does: Opens the claw to release or prepare to grab
How it works: Moves claw servo to 0 degrees (open position)
Example:
car.openClaw(); // Open the claw
delay(1000); // Wait for it to openWhat it does: Closes the claw to grab an object
How it works: Moves claw servo to 180 degrees (closed position)
Example:
car.closeClaw(); // Close the claw
delay(1000); // Wait for it to closeComplete grab sequence:
car.openClaw(); // 1. Open claw
delay(1000);
car.moveForward(100, 800); // 2. Approach object
delay(500);
car.closeClaw(); // 3. Grab object
delay(1500);
car.moveBackward(100, 500); // 4. Back away with objectWhat it does: Sets up the line sensors for use
How it works: Configures the Arduino pins for the three line sensors
Example:
void setup() {
car.initLineSensors(); // Initialize line sensors
}When to use it: ONCE in setup() before reading line sensors
What it does: Reads the left line sensor value
How it works: Measures how much light reflects back from the surface
Returns: A number from 0 to 1023
- LOW (0-300): On a BLACK line (dark, absorbs light)
- HIGH (700-1023): On WHITE surface (bright, reflects light)
- MEDIUM (300-700): Edge of line or gray surface
Example:
int leftValue = car.getLineSensorLeft();
Serial.print("Left sensor: ");
Serial.println(leftValue);
if(leftValue < 500) {
Serial.println("On black line!");
} else {
Serial.println("On white surface");
}What it does: Reads the middle line sensor value
Returns: Same as getLineSensorLeft (0-1023)
What it does: Reads the right line sensor value
Returns: Same as getLineSensorLeft (0-1023)
What it does: Makes the robot follow a black line automatically
How it works:
- If center sensor sees line → go straight
- If left sensor sees line → turn left
- If right sensor sees line → turn right
Parameters:
threshold: Value to distinguish black from white (usually 500)- Values BELOW threshold = on the line (black)
- Values ABOVE threshold = off the line (white)
Example:
car.followLine(500); // Follow line using threshold of 500When to use it: In a loop to continuously follow a line
void loop() {
car.followLine(500);
delay(50); // Small delay for stability
}What it does: Makes the robot wait/pause
How it works: Stops executing code for the specified time
Parameters:
milliseconds: How long to wait- 1000 = 1 second
- 500 = 0.5 seconds
- 100 = 0.1 seconds
Example:
car.moveForward(100, 1000); // Move forward
delay(2000); // Wait 2 seconds
car.moveBackward(100, 1000); // Move backwardWhen to use it:
- Between movements
- After servo commands (let servo reach position)
- To create timing/rhythm
- To pause and observe
What it does: Prints messages to the computer screen
How it works: Sends text through the USB cable to show in Arduino Serial Monitor
Example:
Serial.println("Robot is starting!");
Serial.println("Moving forward...");
Serial.print("Distance: ");
Serial.println(distance);When to use it:
- Debugging (seeing what robot is thinking)
- Status messages
- Showing sensor values
- Understanding what code is doing
Every Arduino program has two main parts:
Runs ONCE when robot starts
Put initialization here:
void setup() {
Serial.begin(9600); // Start serial communication
car.setup(); // Initialize robot
car.attachSensorServo(10); // Connect servos
car.attachClaw(11);
car.initLineSensors(); // Initialize sensors
Serial.println("Ready!");
}Runs OVER and OVER forever
Put your robot behavior here:
void loop() {
// This code runs repeatedly
car.moveForward(150, 1000);
delay(500);
car.turnRight(150, 500);
delay(500);
// When this ends, it starts over from the top
}-
Start with modification, not creation
- Provide working code
- Ask students to change ONE parameter
- Example: "Change the speed from 150 to 200 and see what happens"
-
Use physical analogies
- delay() is like counting "1 Mississippi, 2 Mississippi"
- Speed is like a gas pedal
- Sensors are like your eyes and ears
-
Make it concrete
- Print everything: Serial.println("Doing this now!")
- Use real measurements: "Move forward 30cm" not "for 1000ms"
- Physical markers: tape on floor, objects to navigate
Teach the "Is it...?" checklist:
- Is it uploaded? (Did you click upload?)
- Is it powered? (Batteries charged?)
- Is it in setup or loop? (Setup runs once, loop repeats)
- Did you wait? (delay after servo commands?)
- What do sensors say? (Print the values!)
Common Issues:
- Robot doesn't move: Check batteries, check car.setup() is called
- Servo doesn't work: Did you attach it? Did you wait (delay)?
- Values seem wrong: Calibrate! Different environments need different thresholds
- Code uploads but nothing happens: Is the code in loop() or setup()?
- Robot performs the required task
- Code is uploaded and runs
- Student can explain what the code does
- Includes appropriate Serial.println() messages
- Completed the bonus challenge
- Added unique features
- Code is well-commented
- Demonstrates understanding through modifications
- Helps other students debug
- Extends the challenge creatively
- Explains WHY code works, not just WHAT it does
- Can troubleshoot independently
- Arduino-compatible robot car chassis
- TB6612FNG motor driver
- 2x DC motors
- Ultrasonic sensor (HC-SR04)
- 3x IR line sensors
- 2x Servo motors (for sensor pan and claw)
- Robot claw gripper
- RGB LED (WS2812/NeoPixel)
- Buzzer (optional)
- Battery pack (7.4V recommended)
Motors:
PWMA: Pin 5
PWMB: Pin 6
AIN: Pin 7
BIN: Pin 8
STBY: Pin 3
Ultrasonic Sensor:
TRIG: Pin 13
ECHO: Pin 12
Servos:
Sensor Servo: Pin 10
Claw Servo: Pin 11
Line Sensors:
Left: Pin A2
Middle: Pin A1
Right: Pin A0
Other:
RGB LED: Pin 4
Buzzer: Pin 11 (optional)
Battery Monitor: Pin A3
- Open floor space (2m x 2m minimum)
- Measuring tape
- Tape markers for waypoints
- Charged batteries (spares!)
- Cardboard boxes (various sizes)
- Books or blocks
- Measuring tape
- Tape for marking safe zones
- White poster board or floor space
- Black electrical tape (1.5-2cm wide)
- Pre-made tracks (straight, curved, intersection)
- Bright overhead lighting
- Obstacle course setup
- Line tracks
- Small objects for grabbing (foam blocks, ping pong balls)
- Goal markers
- Timer
After completing all lessons, students can tackle these advanced projects:
-
Sumo Robot
- Two robots compete to push each other out of a ring
- Uses line sensors for ring boundary
- Uses ultrasonic to find opponent
-
Maze Solver
- Navigate unknown maze
- Find the goal (marked with line)
- Remember and return via shortest path
-
Line Following Race
- Follow complex track as fast as possible
- Optimize for speed vs stability
- Handle intersections with decision logic
-
Warehouse Robot
- Multiple pick-up points
- Deliver to correct drop-off zones
- Use color coding or distance markers
-
Autonomous Exploration
- Map an unknown space
- Avoid obstacles
- Return to home base
- Report findings
These lessons align with:
Next Generation Science Standards (NGSS):
- MS-ETS1-1: Define criteria and constraints for design
- MS-ETS1-2: Evaluate competing design solutions
- MS-ETS1-3: Analyze data from tests
- MS-ETS1-4: Develop models to test solutions
CSTA Computer Science Standards:
- 2-AP-13: Decompose problems into sub-problems
- 2-AP-16: Incorporate existing code into programs
- 2-AP-17: Systematically test and refine programs
- 3A-AP-13: Create prototypes using algorithms
- 3A-AP-16: Design and iteratively develop programs
- 3A-AP-18: Explain security measures
Common Core Math:
- CCSS.Math.Practice.MP1: Make sense of problems
- CCSS.Math.Practice.MP2: Reason abstractly
- CCSS.Math.Practice.MP5: Use appropriate tools
Algorithm: Step-by-step instructions to solve a problem Autonomous: Operating independently without human control Calibration: Adjusting sensors for accurate readings Conditional: Code that runs only if a condition is true (if/else) Debug: Finding and fixing errors in code Duration: How long something lasts (in milliseconds) Function: Reusable block of code that does one task Loop: Code that repeats over and over Parameter: Information passed to a function (inside parentheses) Sensor: Device that detects physical properties (distance, light, etc.) Servo: Motor that rotates to specific angles State Machine: System with different modes/states Threshold: Value that triggers a decision (above/below) Variable: Container that stores a value that can change
Created: February 2026 For: WWHS Research - Arduino Robotics Program By: GitHub Copilot Educational Assistant
License: This material is provided for educational use. Please credit the source when sharing or adapting.
End of Comprehensive Lesson Guide Total Lesson Time: Approximately 20-24 hours of instruction Suitable for: Middle School through High School Prerequisites: None - designed for complete beginners