← Back to Bhodi's Materials

Mechatronics Crash Course

A 45-Minute Review for Your NESA Exam, Bodhi!

Part 1: The Big Picture - What IS Mechatronics?

Mechatronics boils down to one simple idea: writing software to control physical things. Think of it like a human body:

🧠 The Brain

Microcontroller (e.g., an Arduino). It runs the code and makes all the decisions.

👂 The Senses

Sensors (e.g., a knob, a light sensor). They gather information from the world. This is your INPUT.

💪 The Muscles

Actuators (e.g., a motor, an LED). They perform actions in the world. This is your OUTPUT.

This gives us the core loop for any mechatronics system: INPUT → PROCESS → OUTPUT

Part 2: The Core Loop in Action (Live Simulation)

Let's see this loop in action. Here's a virtual circuit with our three parts. Click "Start Simulation" and turn the knob (the potentiometer) to see the robot arm (the servo motor) move!

Click "Start Simulation" in the frame

Arduino Code Explained

// Include the library for the servo motor
#include <Servo.h>

// Create a servo object to control a servo
Servo myServo; 

// Define constants for the pins we are using
const int potPin = A0; // Potentiometer (sensor) is on Analog Pin 0
const int servoPin = 9;  // Servo (actuator) is on Digital Pin 9

void setup() {
  // Attach the servo object to its pin
  myServo.attach(servoPin);
}

void loop() {
  // 1. INPUT: Read the value from the sensor (0-1023)
  int potValue = analogRead(potPin);

  // 2. PROCESS: Convert the sensor reading to a servo angle (0-180)
  int angle = map(potValue, 0, 1023, 0, 180);

  // 3. OUTPUT: Tell the servo to move to the calculated angle
  myServo.write(angle);

  // Wait 15 milliseconds to allow the servo to reach its position
  delay(15);
}

Part 3: The Key Exam Concept - Open vs. Closed Loop

Open-Loop System

An open-loop system follows commands but does not use feedback to check if the job was done correctly. It's simple, but not very smart.

Example: A basic toaster. You set the time and it toasts. It doesn't have a sensor to check if your bread is perfectly golden or burnt to a crisp.

Closed-Loop System

A closed-loop system is smarter. It acts, then uses a sensor to get feedback, and then corrects itself. This is the goal for most robotic systems.

Example: A robot vacuum. It moves forward (action), a sensor detects a wall (feedback), and the brain tells the wheels to turn away (correction).
A key term for complex closed-loop systems is PID Control. You just need to know it's a special algorithm for managing feedback and correction precisely.

Part 4: Connecting to OOP & Exam Prep

Connecting to OOP

How could we make our servo code better with Object-Oriented Programming? We could create a class RoboticArm.

  • Attributes: servoPin, currentAngle.
  • Methods: .moveTo(angle), .readPosition().

OOP helps organise complex hardware into reusable, logical blocks.

Interactive Exam Questions

Q1: A smart cat feeder needs to dispense 1 cup of food at 8 AM. Describe the components it would need.

Q2: A self-driving car must stay in its lane. Justify why it must use a closed-loop system.

Part 5: Exam Cheat Sheet

If you remember nothing else, remember these four things:

  • ✅ The Core Loop: Input (Sensor) → Process (Microcontroller) → Output (Actuator).
  • ✅ Open-Loop: Follows orders, no feedback, not smart. (Toaster)
  • ✅ Closed-Loop: Uses sensor feedback to check and correct itself. (Robot Vacuum)
  • ✅ Key Vocab: Microcontroller, Sensor, Actuator, PID Control.