Robot Building Blocks: Sensors, Actuators, Controllers and Power

A line follower, a robotic arm and a self-balancing robot look very different, but each one is built from the same four subsystems: sensors that measure the world, actuators that move something, a controller that decides what to do, and a power system that keeps everything running. If you can name the part that fills each role and check that the four parts are compatible, you can plan almost any hobby robot before you buy a single component.

This article explains each block with real parts you will find in Indian electronics shops and online stores, shows how they connect electrically, and ends with a small Arduino sketch that implements the classic sense-think-act loop using one sensor and one motor. Later tutorials in this series build on these ideas one subsystem at a time.

The Sense-Think-Act Loop

Every autonomous robot runs a loop. It reads its sensors, computes a decision, and drives its actuators. Then it repeats, often hundreds of times per second. The speed of this loop matters: a line follower that updates its motors only five times a second will overshoot every curve, while a balancing robot needs a loop running at 100 Hz or faster to stay upright.

   +-----------+      +--------------+      +-------------+
   |  SENSORS  | ---> |  CONTROLLER  | ---> |  ACTUATORS  |
   +-----------+      +--------------+      +-------------+
         ^                   ^                     |
         |              POWER SYSTEM               |
         +------------ environment <---------------+

The arrow from actuators back to sensors through the environment is what makes this a closed loop. When the robot turns, the sensor reading changes, and the controller sees the result of its own action. Designs that ignore this feedback, such as running a motor for a fixed time and hoping it travelled the right distance, are called open loop and are much less accurate.

The Four Blocks in Detail

Sensors

Sensors convert a physical quantity into a voltage or a digital message. For beginners the most useful are IR reflectance sensors such as the TCRT5000 for line detection, the HC-SR04 ultrasonic module for distance, wheel encoders for rotation counting, and the MPU6050 accelerometer-gyroscope for tilt. Note the output type of each one: analog voltage, digital high/low, a timed pulse, or an I2C bus, because that decides which controller pins you need.

Actuators

Actuators produce motion. Brushed DC gear motors drive wheels, hobby servos such as the SG90 and MG996R hold an angle, and stepper motors such as the NEMA 17 move in precise steps. A microcontroller pin can supply only a few milliamps, so a DC or stepper motor always needs a driver between the controller and the motor. Servos contain their own driver and only need a signal wire, though they still need a power supply that can deliver their current.

Controller

The controller is usually a microcontroller board. The Arduino Uno (ATmega328P) is the common starting point, the ESP32 adds Wi-Fi and Bluetooth, and a Raspberry Pi is used when you need Linux, a camera or ROS 2. Many advanced robots use both: a Raspberry Pi for high-level planning and an Arduino or ESP32 for real-time motor control.

Power

The power system includes the battery, any voltage regulators, a switch and ideally a fuse. Motors draw large and sudden currents, so they normally run directly from the battery through the driver, while the logic gets a clean regulated 5 V or 3.3 V. Most strange robot faults, such as random resets when motors start, come from a weak power design rather than from code.

Choosing Compatible Parts

The table below shows a typical beginner combination and what you must check between the blocks.

BlockExample partWhat to check
SensorHC-SR04 ultrasonicRuns on 5 V; its echo output is 5 V, so a 3.3 V board needs a divider
SensorTCRT5000 IR moduleDigital output plus optional analog output; sensitivity set by trimmer
ActuatorBO or N20 DC gear motorRated voltage and stall current, which the driver must handle
DriverL298N or TB6612FNGMotor supply voltage range and current per channel
ControllerArduino UnoEnough PWM pins (3, 5, 6, 9, 10, 11) and interrupt pins (2, 3)
Power2S Li-ion pack, 7.4 V nominalVoltage suits the motors; capacity gives the run time you need

A Minimal Sense-Think-Act Sketch

The sketch below uses an HC-SR04 as the sensor and one DC motor through an L298N channel as the actuator. If an object is closer than 20 cm the motor stops, otherwise it runs at moderate speed. Connect TRIG to pin 9, ECHO to pin 10, the driver ENA to pin 5 (PWM), IN1 to pin 7 and IN2 to pin 8.

Sense-think-act loop: stop the motor when an obstacle is near
// Sense-think-act demo: HC-SR04 sensor + one DC motor on an L298N channel
const int TRIG_PIN = 9;
const int ECHO_PIN = 10;
const int ENA_PIN  = 5;   // PWM pin controls motor speed
const int IN1_PIN  = 7;   // direction pins
const int IN2_PIN  = 8;

const int STOP_DISTANCE_CM = 20;
const int CRUISE_SPEED = 150;   // 0-255 PWM duty

// SENSE: measure distance in centimetres (returns -1 on timeout)
long readDistanceCm() {
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);      // 10 us trigger pulse
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);
  unsigned long t = pulseIn(ECHO_PIN, HIGH, 30000UL); // 30 ms timeout
  if (t == 0) return -1;             // no echo: nothing in range
  return (long)(t * 0.0343 / 2.0);   // speed of sound ~343 m/s, round trip
}

// ACT: run the motor forward at a given speed (0 = stop)
void setMotor(int speed) {
  digitalWrite(IN1_PIN, HIGH);
  digitalWrite(IN2_PIN, LOW);
  analogWrite(ENA_PIN, speed);
}

void setup() {
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
  pinMode(ENA_PIN, OUTPUT);
  pinMode(IN1_PIN, OUTPUT);
  pinMode(IN2_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  long d = readDistanceCm();                    // SENSE
  bool blocked = (d > 0 && d < STOP_DISTANCE_CM); // THINK
  setMotor(blocked ? 0 : CRUISE_SPEED);         // ACT

  Serial.print("Distance: ");
  Serial.print(d);
  Serial.println(blocked ? " cm -> STOP" : " cm -> RUN");
  delay(60);  // HC-SR04 needs about 60 ms between measurements
}

Even this tiny program has all three stages clearly separated into functions. Keeping that structure as your robot grows makes it easy to swap a sensor or change the decision logic without rewriting the whole sketch.

Common Beginner Mistakes

  • Powering motors from the Arduino 5 V pin. The board's regulator and USB port cannot supply motor current, and the board resets.
  • Forgetting the common ground between the motor battery and the controller.
  • Choosing a 3.3 V controller such as the ESP32 and feeding it 5 V sensor outputs directly.
  • Using delay() for long periods inside the loop, which freezes sensing while the robot keeps moving.
  • Buying motors before checking that the driver can supply their stall current.

Summary

Every robot is sensors, actuators, a controller and power, tied together by a sense-think-act loop. Plan each block on paper, check voltage levels, current ratings and pin types between neighbouring blocks, and give the motors their own supply path. With that checklist in mind, the next tutorials look at choosing motors, motor drivers and batteries in detail.