Robot Safety & Build Planning
Robotics combines code, current, motion, and mechanical risk. Learners start with safe power, stable wiring, and testable design.
- Disconnect power before rewiring.
- Keep wheels off the ground for first motor tests.
- Separate logic power from motor power when required.
- Use motor drivers instead of GPIO pins for motors.
Create a pre-power checklist and test motor code with the robot lifted off the table.
Power & Motor Drivers
Motors draw more current than logic pins can supply. Learners use motor drivers, shared ground, and separate power planning.
- GPIO signals control drivers; they do not power motors directly.
- Motor supplies must match motor requirements.
- Ground must be shared between controller and driver.
- Brownouts happen when motors steal current from the controller.
Draw and wire a controller, motor driver, battery pack, and motor with a shared ground.
DC Motors
DC motors teach direction, speed, and driver control. Learners run forward, reverse, stop, and simple speed changes.
- IN1/IN2 often control direction.
- PWM controls average speed.
- Stop can mean coast or brake depending on driver behavior.
- Test one motor before controlling two.
Write code to run one motor forward, stop, reverse, and stop again.
Servos
Servos move to an angle rather than spinning continuously. Learners use them for steering, doors, arms, and sensor mounts.
- A standard servo expects timed control pulses.
- Servos need enough current.
- Mechanical limits matter.
- Jitter often means power or signal issues.
Move a servo between three angles and document its safe mechanical range.
Ultrasonic Distance Sensors
Distance sensors let robots detect walls and obstacles. Learners read trigger/echo timing and convert it into distance.
- Trigger pulse starts measurement.
- Echo duration represents travel time.
- Soft surfaces and angles can affect readings.
- Multiple readings should be filtered.
Print distance readings and test against near, medium, and far objects.
Line Sensors
Line sensors teach surface detection and feedback. Learners read reflected light and decide whether the robot is over a dark or light line.
- Sensors need calibration for the actual surface.
- Thresholds separate line from background.
- Two sensors can steer left or right.
- Lighting changes can affect readings.
Record sensor values over line and background, then choose a threshold.
Encoders
Encoders measure wheel movement. Learners understand ticks, speed estimation, and why dead reckoning drifts.
- Ticks count wheel rotation.
- Wheel diameter affects distance calculation.
- Slipping wheels create error.
- Interrupts often read encoder pulses.
Spin a wheel slowly and count encoder ticks in Serial output.
Joystick & Manual Control
Before autonomy, learners build manual control to verify drive direction, steering, and response.
- Map joystick axes to motor speed.
- Dead zones prevent drift.
- Manual mode helps debug hardware.
- Start at low speed.
Use a joystick or button controls to drive forward, reverse, left, and right.
Obstacle Avoidance
Learners combine distance sensing with motor decisions so a rover can stop, turn, and continue.
- Read distance.
- Compare to a threshold.
- Stop before collision.
- Turn and re-check.
- Avoid rapid oscillation with delays or states.
Program the rover to stop before an obstacle and turn away.
Robot State Machines
State machines make robot behavior easier to reason about than giant nested if statements.
- IDLE
- DRIVE_FORWARD
- AVOID_OBSTACLE
- TURN_LEFT
- ERROR
Refactor obstacle avoidance into named states and print the current state.
Calibration & Testing
Robots need repeatable tests. Learners tune thresholds, speeds, turn times, and sensor positions.
- Test one subsystem at a time.
- Record values before changing thresholds.
- Use slow speeds first.
- Document known limitations.
Create a test sheet with pass/fail rows for motors, sensors, turns, and obstacle avoidance.
Capstone: Autonomous Rover
The capstone combines safe wiring, motors, distance sensing, line or obstacle logic, manual mode, and documentation.
- Manual drive mode works.
- Obstacle avoidance works.
- Status LED or serial output explains state.
- Battery and wiring are secured.
- README includes wiring diagram and test results.
Build and demo an autonomous rover that avoids obstacles and includes a documented test plan.