Mechanical system
Chassis, brackets, wheels, gears, bearings, linkages and the physical geometry that determines what the robot can reach and how it moves.
A robot is more than a motorised chassis. It is a coordinated system of mechanics, electronics, sensing, actuation, power and software. Learn how these parts work together, then design and programme a small differential-drive rover.
A mechatronic system combines mechanical structures, electrical/electronic hardware, sensors, actuators and embedded control. A robot uses these elements to sense its environment or internal state and perform actions. Autonomy can be simple, such as following a line, or complex, such as mapping and navigating an unfamiliar space.
System-level view. The exact power distribution, grounding and protection depend on the chosen hardware.
Chassis, brackets, wheels, gears, bearings, linkages and the physical geometry that determines what the robot can reach and how it moves.
Battery or supply, regulators, motor drivers, wiring, protection, connectors and the distribution of power to each subsystem.
Sensors measure the world or the robot itself. Firmware interprets those measurements and commands actuators to achieve a task.
Mechanical alignment, electrical noise, software timing, heat, cable routing and maintainability can make or break an otherwise good design.
Two independently driven wheels create forward motion, reverse motion and turning by changing the relative wheel speeds. Simple, compact and common in educational mobile robots.
Steered front wheels and driven wheels create a turning radius like a car. Useful for vehicle-like motion, but steering geometry and turning limits add complexity.
Tracks spread load and can improve traction on some surfaces. Turning by skid steering can waste energy and place higher loads on motors and gearboxes.
Legs, arms and linkages add degrees of freedom. They need careful mechanical design, actuator sizing, kinematics and coordinated control.
There is no universally best robot layout. Start with the task, terrain, payload, speed, accuracy, cost, energy budget and maintenance requirements.
For a two-wheel differential-drive robot, let the left and right wheel linear velocities be (v_L) and (v_R), and let the distance between wheel contact centres be (b). The ideal centre-line velocity is their average. The yaw rate depends on their difference.
v = (vR + vL) / 2ω = (vR − vL) / bR = v / ω when ω is not zeroConceptual top view. Real robots experience wheel slip, caster drag, uneven floors, backlash and imperfect wheel diameters.
Enter wheel dimensions and wheel speeds. Positive RPM means forward wheel rotation; negative RPM means reverse. This ideal model assumes both wheels roll without slipping.
Ideal rolling model. Actual speed depends on load, motor performance and traction.
Ultrasonic and time-of-flight sensors estimate distance to nearby objects. Their fields of view, minimum range, reflectivity sensitivity and update rates differ.
Reflective IR sensors distinguish surface reflectance. Calibration matters because floor colour, height, sunlight and sensor geometry affect readings.
Measure wheel rotation and estimate travelled distance. Encoder odometry accumulates error from slip, wheel mismatch, missed pulses and mechanical play.
Accelerometers and gyroscopes measure acceleration and angular rate. Bias, vibration and integration drift must be understood before relying on orientation estimates.
If a wheel has circumference C = π × D and rotates through N counted encoder counts from a documented count resolution Q, its ideal travel estimate is s = (N / Q) × C. For a differential-drive robot, the difference between left and right wheel travel also estimates heading change. These estimates drift over time and should be checked against external references when accuracy matters.
Different sensors have different noise, bias, latency, update rates and failure modes. A robust design checks whether a reading is plausible, timestamps measurements, handles missing data and chooses a suitable estimator. Do not treat a hobby ultrasonic sensor as a certified collision-prevention or life-safety device.
A useful robot firmware architecture separates sensing, estimation, behaviour decisions, motion commands and low-level motor control. This makes it easier to replace a sensor or motor driver without rewriting the whole behaviour.
For a line-following rover, states might include STARTUP, FOLLOW_LINE, LINE_LOST, OBSTACLE_STOP and FAULT. Each state defines what sensor data is required, what motor commands are permitted, and what event causes a transition. A fault state should stop or otherwise place the robot into a hazard-appropriate safe condition.
This practical uses a two-wheel differential-drive chassis. Three downward-facing reflective IR sensors detect the line; the controller adjusts the two motor speeds to steer. Start on a matte, high-contrast track with gentle curves.
The three sensors are shown near the front of the chassis. Adjust height and spacing according to the sensor module and line width.
| Controller pin | Connects to | Purpose |
|---|---|---|
| D5 | Driver PWMA | Left motor PWM |
| D7 / D8 | Driver AIN1 / AIN2 | Left motor direction |
| D6 | Driver PWMB | Right motor PWM |
| D9 / D10 | Driver BIN1 / BIN2 | Right motor direction |
| D4 | Driver STBY | Driver enable |
| D A0 / A1 / A2 | Left / centre / right sensor outputs | Line detection |
| 5V / GND | Sensor logic supply / common reference | Only if sensor logic is 5 V compatible |
| Motor supply | Driver VM and supply ground | Motor power, not GPIO |
Follow the exact breakout-board pinout. Connect controller ground, driver ground, sensor ground and motor-supply negative to a common reference for this non-isolated design. Do not connect the motor supply positive to the controller 5 V rail unless the board's power design explicitly permits it.
Assumption: the digital sensor outputs read LOW over the dark line and HIGH over the lighter floor. Verify this with the Serial Monitor before moving the robot. Some sensor boards use the opposite logic or adjustable comparators.
// Arduino Uno-compatible board + TB6612FNG-style dual driver
const byte PWMA = 5, AIN1 = 7, AIN2 = 8;
const byte PWMB = 6, BIN1 = 9, BIN2 = 10;
const byte STBY = 4;
const byte LEFT_SENSOR = A0;
const byte CENTRE_SENSOR = A1;
const byte RIGHT_SENSOR = A2;
const int BASE_SPEED = 105; // start conservatively
const int TURN_ADJUST = 65;
const int MAX_PWM = 180;
const bool LINE_IS_LOW = true;
bool readLine(byte pin) {
int value = digitalRead(pin);
return LINE_IS_LOW ? value == LOW : value == HIGH;
}
void setMotor(byte pwm, byte in1, byte in2, int command) {
command = constrain(command, -MAX_PWM, MAX_PWM);
if (command >= 0) {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(pwm, command);
} else {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(pwm, -command);
}
}
void drive(int left, int right) {
setMotor(PWMA, AIN1, AIN2, left);
setMotor(PWMB, BIN1, BIN2, right);
}
void stopRobot() {
analogWrite(PWMA, 0);
analogWrite(PWMB, 0);
}
void setup() {
pinMode(PWMA, OUTPUT); pinMode(AIN1, OUTPUT); pinMode(AIN2, OUTPUT);
pinMode(PWMB, OUTPUT); pinMode(BIN1, OUTPUT); pinMode(BIN2, OUTPUT);
pinMode(STBY, OUTPUT);
pinMode(LEFT_SENSOR, INPUT);
pinMode(CENTRE_SENSOR, INPUT);
pinMode(RIGHT_SENSOR, INPUT);
digitalWrite(STBY, LOW);
Serial.begin(115200);
// Confirm sensor polarity and motor direction before enabling movement.
digitalWrite(STBY, HIGH);
}
void loop() {
bool left = readLine(LEFT_SENSOR);
bool centre = readLine(CENTRE_SENSOR);
bool right = readLine(RIGHT_SENSOR);
Serial.print(left); Serial.print(' ');
Serial.print(centre); Serial.print(' ');
Serial.println(right);
if (centre && !left && !right) {
drive(BASE_SPEED, BASE_SPEED);
} else if (left && !right) {
drive(BASE_SPEED - TURN_ADJUST, BASE_SPEED + TURN_ADJUST);
} else if (right && !left) {
drive(BASE_SPEED + TURN_ADJUST, BASE_SPEED - TURN_ADJUST);
} else if (left && centre && right) {
// Wide line or junction: proceed slowly.
drive(BASE_SPEED / 2, BASE_SPEED / 2);
} else if (!left && !centre && !right) {
// Lost line: stop rather than searching blindly.
stopRobot();
} else {
// Ambiguous pattern: stop and inspect the track/sensor spacing.
stopRobot();
}
delay(5);
}This is a simple teaching baseline, not a robust competition line follower. Sensor polarity, motor direction, PWM minimum, wheel mismatch and turn behaviour must be calibrated on the actual build. It stops when the line is lost instead of making an unbounded search turn. Add encoder feedback, controlled reacquisition and a non-blocking state machine as later improvements.
Estimate current for motors, controller, sensors and accessories. Motor startup and stall current can dominate. Check battery discharge capability, regulator thermal limits, wiring and connector ratings.
Check fasteners, shaft alignment, wheel concentricity, gear backlash, centre of gravity, payload mounting and cable strain relief. Loose structures create inconsistent sensor and motion behaviour.
Brushed motors create switching noise. Follow driver guidance for local bypass capacitors, short current loops, grounding and separation of motor and sensor wiring. Investigate resets and false sensor readings.
Use startup checks, bounded motor commands, timeouts, sensor plausibility checks and explicit fault handling. A communication or sensor fault should not leave the robot driving indefinitely.
Use encoder counts to command a measured straight-line distance. Compare expected and actual travel, then calibrate effective wheel circumference.
Add a front distance sensor. Define clear states for line following, obstacle stop, obstacle cleared and sensor fault. Never assume one distance reading is always valid.
Use left and right encoders to regulate both wheel speeds independently. Investigate how unequal motor characteristics affect straight-line travel.
Compare wheel odometry with IMU heading and external position references. Record drift and identify when sensor fusion or a different localisation method is justified.
Explore these open lessons at your own pace. For personalised explanations, project-specific troubleshooting, guided practical training or masterclasses, EazyLife offers paid support tailored to your learning goals.
Free or sponsored lesson referrals may be available through active programmes; they are not guaranteed.