Chassis and Drive Configuration

The most common beginner chassis is an acrylic two-layer platform with two DC gear motors and a rear caster wheel, sold under various brand names at Polish distributors for 40–80 PLN. The typical motor used is a 3–6 V DC gear motor with a plastic gearbox, outputting 100–200 RPM at 6 V. These are adequate for a first project but wear out within a few months of daily use; metal-gear versions cost more but last considerably longer.

Four-wheel drive (4WD) chassis use four motors and offer more traction on rough surfaces, but require two H-bridge drivers or a single driver with four channels. For indoor, hard-floor use the standard two-motor configuration is sufficient and significantly simpler to wire.

Motor Driver Boards

DC motors draw more current than an Arduino output pin can supply and require the ability to reverse direction — neither of which GPIO pins can do directly. A dedicated H-bridge motor driver sits between the Arduino and the motors.

L298N

The L298N dual H-bridge module is the most common choice at the beginner level. It handles two motors at up to 2 A each (4 A peak), accepts a logic supply from the Arduino's 5 V pin, and takes a separate motor power supply of 5–35 V via its own terminal block. On the downside, the L298N has a voltage drop of 1.5–2 V across its output stage — at 6 V motor supply, the motors only see 4–4.5 V, reducing torque. Price in Poland: 15–25 PLN.

L9110S and TB6612FNG

The L9110S module is a lower-dropout alternative rated at 800 mA per channel — adequate for light chassis motors. The TB6612FNG is a MOSFET-based driver with a much smaller voltage drop (0.1–0.2 V), handling up to 1.2 A continuous per channel, and is the preferred choice when motor efficiency matters. Both are available for 10–20 PLN.

Arduino Nano compact board often used in robot builds to save chassis space

Arduino Nano — a compact alternative to the Uno, useful when chassis space is limited. Same ATmega328P, same pin functions, smaller footprint. Image: Wikimedia Commons, CC BY-SA.

Distance Sensing with HC-SR04

The HC-SR04 ultrasonic sensor measures distances from approximately 2 cm to 400 cm by emitting a 40 kHz pulse and measuring the time for the echo to return. The calculation is straightforward: distance in centimetres equals pulse duration in microseconds divided by 58. The sensor operates at 5 V and requires two GPIO pins: one for the trigger pulse (10 µs minimum) and one to read the echo signal.

On an Arduino Uno, the pulseIn() function captures the echo duration. The function blocks execution while waiting — typically 1–30 ms depending on distance — so the sensor is usually polled once per main loop iteration rather than in a tight loop. For more reliable timing at short distances, the HC-SR04 interrupt-based library is available as an alternative.

Power Supply Strategy

Running the Arduino and motors from a single battery pack is the simplest wiring arrangement but creates a risk: when motors draw surge current on startup or under load, the supply voltage drops, which can reset the Arduino mid-operation. Two approaches reduce this:

  • Separate supplies: A dedicated 4× AA or 6× AA holder (6 V) feeds the motor driver VCC terminal; the Arduino is powered separately via USB or its own regulator. A shared ground between the two supplies is required.
  • Large bulk capacitor: A 1000–4700 µF electrolytic capacitor across the motor supply terminals acts as a local energy reservoir, absorbing current spikes before they affect the logic supply.

Lithium polymer packs (7.4 V, 1000–2000 mAh) offer better energy density and flatter discharge curves than alkaline AA cells. They require a dedicated charger and appropriate handling — they are unsuitable for a robot left unattended or stored in a closed container while charging.

Basic Obstacle Avoidance Loop

The control loop for a simple obstacle-avoiding robot operates as follows:

  1. Measure distance with HC-SR04
  2. If distance > 25 cm: drive both motors forward
  3. If distance ≤ 25 cm: stop both motors, pause 200 ms
  4. Reverse both motors for 300 ms
  5. Stop, then drive one motor forward and the other in reverse for 400 ms (pivot turn)
  6. Return to step 1

The specific timing values in steps 4–5 depend on the motor speed and chassis dimensions — they require calibration on the actual hardware. This structure is easy to understand but produces erratic behaviour in tight spaces with many obstacles because it has no memory of previous turns. Adding a second sensor (rear-facing, or side-facing) and tracking the last turn direction produces more consistent behaviour without significantly more code complexity.

Line-Following as an Alternative Starting Project

Line-following robots use infrared reflectance sensors (TCRT5000 modules, typically 10–20 PLN for a pair) mounted beneath the chassis to detect a dark line on a light surface. Each sensor returns a digital HIGH when over the light surface and LOW over the dark line. The control logic is simpler than obstacle avoidance:

  • Both sensors detect light → drive straight
  • Left sensor detects dark → turn left
  • Right sensor detects dark → turn right
  • Both detect dark → line lost, stop or execute recovery

A 3-sensor array (left, centre, right) with proportional speed correction instead of full on/off turns produces much smoother tracking and is the standard setup for line-following competitions at Polish robotics events such as Robotic Arena (Wrocław) and Robocomp (Kraków).

Related Reading

Arduino

Getting Started with Arduino Uno

Hardware layout, pin functions, power specifications, and uploading your first sketch to an Arduino Uno board.

Read more

Raspberry Pi

Raspberry Pi Home Automation

GPIO wiring, relay control, temperature sensors, and running automations locally on Raspberry Pi hardware.

Read more