Module 3: Power & Wiring Basics

Level: 🟢 Beginner Board: Arduino Uno Prerequisites: Module 02 Estimated time: 45–60 minutes Goal: Wire the power subsystem so the Arduino and L298N run from the battery pack safely.


What You'll Learn

By the end of this module you will understand how voltage, current, and resistance relate to your robot's power system. You will be able to identify every terminal on the L298N motor driver, wire a battery-powered circuit on a breadboard, and connect all components with a shared ground reference. Most beginners treat wiring as the part you do quickly before getting to the interesting code. That attitude is what causes the magic smoke.


3.1 Voltage, current, and resistance

You do not need to pass an electronics exam to wire a robot. You need to understand three concepts well enough to make good decisions, and to read a datasheet when something smells wrong.

Want to know why? (optional read): Voltage is the pressure that pushes current through a circuit. Current is the flow rate: how many electrons pass a point per second. Resistance is opposition to that flow. Ohm's Law ties the three together: V = I × R. Change one and at least one of the others must change to compensate. You will not need to solve this equation during the labs, but it explains why undersized wires overheat and why the HC-05 needs a voltage divider.

<svg viewBox="0 0 760 310" width="100%" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <marker id="aB" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M2 2L8 5L2 8" fill="none" stroke="#1a1a18" stroke-width="1.5" stroke-linecap="round"/></marker>
        <marker id="aW" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M2 2L8 5L2 8" fill="none" stroke="#1f4d8c" stroke-width="1.5" stroke-linecap="round"/></marker>
      </defs>

      <!-- VOLTAGE — pump analogy -->
      <text x="125" y="22" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" letter-spacing="1" fill="#c8420a">VOLTAGE (V)</text>
      <text x="125" y="38" text-anchor="middle" font-family="Manrope,sans-serif" font-size="11" fill="#6b6a65">electrical pressure</text>
      <rect x="50" y="50" width="60" height="80" rx="4" fill="#b0d0f0" stroke="#1f4d8c" stroke-width="1.5"/>
      <text x="80" y="100" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#1f4d8c">HIGH</text>
      <rect x="110" y="118" width="80" height="14" rx="3" fill="#1f4d8c"/>
      <line x1="120" y1="125" x2="180" y2="125" stroke="white" stroke-width="1.5" marker-end="url(#aW)"/>
      <rect x="190" y="110" width="60" height="30" rx="4" fill="#d0e8f8" stroke="#1f4d8c" stroke-width="1.5"/>
      <text x="220" y="130" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#1f4d8c">LOW</text>
      <rect x="50" y="140" width="60" height="22" rx="3" fill="#1f4d8c"/>
      <text x="80" y="155" text-anchor="middle" font-family="Manrope,sans-serif" font-size="10" fill="white">battery</text>
      <line x1="80" y1="162" x2="80" y2="130" stroke="#1f4d8c" stroke-width="1"/>
      <line x1="270" y1="52" x2="270" y2="160" stroke="#c8420a" stroke-width="1.5"/>
      <line x1="265" y1="52" x2="275" y2="52" stroke="#c8420a" stroke-width="1.5"/>
      <line x1="265" y1="160" x2="275" y2="160" stroke="#c8420a" stroke-width="1.5"/>
      <text x="285" y="110" font-family="IBM Plex Mono,monospace" font-size="11" fill="#c8420a">= 6V</text>
      <text x="285" y="126" font-family="Manrope,sans-serif" font-size="10" fill="#6b6a65">potential</text>
      <text x="285" y="140" font-family="Manrope,sans-serif" font-size="10" fill="#6b6a65">difference</text>

      <!-- CURRENT — pipe width analogy -->
      <text x="460" y="22" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" letter-spacing="1" fill="#1a6b4a">CURRENT (A)</text>
      <text x="460" y="38" text-anchor="middle" font-family="Manrope,sans-serif" font-size="11" fill="#6b6a65">flow rate — how much per second</text>
      <rect x="340" y="80" width="120" height="8" rx="3" fill="#aaa"/>
      <text x="340" y="74" font-family="Manrope,sans-serif" font-size="11" fill="#6b6a65">thin wire → low current</text>
      <rect x="340" y="130" width="120" height="22" rx="4" fill="#3d3c38"/>
      <text x="340" y="170" font-family="Manrope,sans-serif" font-size="11" fill="#6b6a65">thick wire → high current</text>
      <line x1="350" y1="84" x2="445" y2="84" stroke="white" stroke-width="1" marker-end="url(#aW)"/>
      <line x1="350" y1="141" x2="445" y2="141" stroke="white" stroke-width="1.5" marker-end="url(#aW)"/>
      <text x="460" y="86" font-family="IBM Plex Mono,monospace" font-size="10" fill="#aaa">~50mA</text>
      <text x="460" y="143" font-family="IBM Plex Mono,monospace" font-size="10" fill="#ddd">~1A</text>

      <!-- RESISTANCE — narrow section -->
      <text x="460" y="230" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" letter-spacing="1" fill="#c8b400">RESISTANCE (Ω)</text>
      <text x="460" y="246" text-anchor="middle" font-family="Manrope,sans-serif" font-size="11" fill="#6b6a65">opposition to flow</text>
      <rect x="340" y="258" width="40" height="20" rx="3" fill="#3d3c38"/>
      <rect x="380" y="264" width="30" height="8" rx="2" fill="#c8b400"/>
      <rect x="410" y="258" width="50" height="20" rx="3" fill="#3d3c38"/>
      <text x="395" y="256" text-anchor="middle" font-family="Manrope,sans-serif" font-size="10" fill="#c8b400">resistor</text>
      <text x="395" y="292" text-anchor="middle" font-family="Manrope,sans-serif" font-size="10" fill="#6b6a65">narrows flow, drops voltage</text>

      <!-- Ohm's Law box -->
      <rect x="590" y="50" width="150" height="220" rx="6" fill="#1a1a18"/>
      <text x="665" y="76" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" fill="#888">Ohm's Law</text>
      <text x="665" y="110" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="22" fill="#f5f2eb">V = I×R</text>
      <line x1="610" y1="126" x2="730" y2="126" stroke="#333" stroke-width="1"/>
      <text x="665" y="152" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" fill="#888">V = voltage (volts)</text>
      <text x="665" y="170" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" fill="#888">I = current (amps)</text>
      <text x="665" y="188" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" fill="#888">R = resistance (Ω)</text>
      <line x1="610" y1="202" x2="730" y2="202" stroke="#333" stroke-width="1"/>
      <text x="665" y="220" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="10" fill="#c8420a">6V ÷ 10Ω = 0.6A</text>
      <text x="665" y="238" text-anchor="middle" font-family="Manrope,sans-serif" font-size="10" fill="#666">example only</text>
      <text x="665" y="256" text-anchor="middle" font-family="Manrope,sans-serif" font-size="10" fill="#666">three numbers,</text>
      <text x="665" y="270" text-anchor="middle" font-family="Manrope,sans-serif" font-size="10" fill="#666">always in balance</text>
    </svg>

Fig 3.1: Voltage, current, and resistance using the water analogy. Voltage is the pressure difference between two points (reservoir height). Current is the flow rate: thicker pipe, more flow. Resistance restricts flow and drops voltage across the restriction. Ohm's Law ties the three numbers together: change one and one of the others must change to compensate.

For your robot, the numbers that matter are simple. The battery pack produces 6V. The motors draw roughly 200–400mA running freely and up to 1.2A when stalled against a wall. The Arduino logic runs on 5V and draws about 50mA. The motor driver handles the current difference between those two domains so the Arduino never has to. Its output pins can only supply about 40mA each, not nearly enough to spin a motor directly.


3.2 Battery types and capacity

Your kit uses a 4×AA battery holder. Four AA cells in series gives 6V, which sits comfortably in the operating range of both the motor driver and the Arduino's Vin input. The relevant number on a battery is its capacity, measured in milliamp-hours (mAh). A 2,000mAh AA cell can deliver 200mA for 10 hours, or 2,000mA for one hour. The product of current and time always equals the capacity.

<svg viewBox="0 0 760 290" width="100%" xmlns="http://www.w3.org/2000/svg">

      <!-- 4xAA holder -->
      <text x="130" y="22" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" letter-spacing="1" fill="#6b6a65">4× AA IN SERIES</text>
      <g>
        <rect x="30" y="40" width="44" height="80" rx="4" fill="#c8b400" stroke="#8a7a00" stroke-width="1.5"/>
        <rect x="48" y="32" width="10" height="10" rx="2" fill="#c8b400" stroke="#8a7a00" stroke-width="1.5"/>
        <text x="52" y="82" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#1a1a18">1.5V</text>
        <rect x="84" y="40" width="44" height="80" rx="4" fill="#c8b400" stroke="#8a7a00" stroke-width="1.5"/>
        <rect x="102" y="32" width="10" height="10" rx="2" fill="#c8b400" stroke="#8a7a00" stroke-width="1.5"/>
        <text x="106" y="82" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#1a1a18">1.5V</text>
        <rect x="138" y="40" width="44" height="80" rx="4" fill="#c8b400" stroke="#8a7a00" stroke-width="1.5"/>
        <rect x="156" y="32" width="10" height="10" rx="2" fill="#c8b400" stroke="#8a7a00" stroke-width="1.5"/>
        <text x="160" y="82" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#1a1a18">1.5V</text>
        <rect x="192" y="40" width="44" height="80" rx="4" fill="#c8b400" stroke="#8a7a00" stroke-width="1.5"/>
        <rect x="210" y="32" width="10" height="10" rx="2" fill="#c8b400" stroke="#8a7a00" stroke-width="1.5"/>
        <text x="214" y="82" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#1a1a18">1.5V</text>
        <line x1="74" y1="38" x2="84" y2="38" stroke="#c8420a" stroke-width="2"/>
        <line x1="128" y1="38" x2="138" y2="38" stroke="#c8420a" stroke-width="2"/>
        <line x1="182" y1="38" x2="192" y2="38" stroke="#c8420a" stroke-width="2"/>
        <text x="130" y="145" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="13" fill="#c8420a">= 6.0V total</text>
        <text x="130" y="162" text-anchor="middle" font-family="Manrope,sans-serif" font-size="11" fill="#6b6a65">series: voltages add</text>
        <text x="130" y="178" text-anchor="middle" font-family="Manrope,sans-serif" font-size="11" fill="#6b6a65">capacity stays same as one cell</text>
      </g>

      <!-- Capacity bar chart -->
      <text x="460" y="22" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" letter-spacing="1" fill="#6b6a65">mAh — WHAT IT MEANS</text>
      <line x1="340" y1="200" x2="600" y2="200" stroke="#c4bfb0" stroke-width="1"/>
      <line x1="340" y1="50" x2="340" y2="200" stroke="#c4bfb0" stroke-width="1"/>
      <rect x="360" y="120" width="40" height="80" fill="#c8b400" stroke="#8a7a00" stroke-width="1"/>
      <text x="380" y="116" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#8a7a00">800</text>
      <text x="380" y="214" text-anchor="middle" font-family="Manrope,sans-serif" font-size="9" fill="#6b6a65">cheap AA</text>
      <rect x="420" y="80" width="40" height="120" fill="#c8b400" stroke="#8a7a00" stroke-width="1" opacity=".8"/>
      <text x="440" y="76" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#8a7a00">2000</text>
      <text x="440" y="214" text-anchor="middle" font-family="Manrope,sans-serif" font-size="9" fill="#6b6a65">good AA</text>
      <rect x="480" y="60" width="40" height="140" fill="#1a6b4a" stroke="#0e4030" stroke-width="1"/>
      <text x="500" y="56" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#1a6b4a">2500</text>
      <text x="500" y="214" text-anchor="middle" font-family="Manrope,sans-serif" font-size="9" fill="#6b6a65">NiMH AA</text>
      <rect x="540" y="50" width="40" height="150" fill="#1f4d8c" stroke="#0e3060" stroke-width="1"/>
      <text x="560" y="46" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#1f4d8c">3000+</text>
      <text x="560" y="214" text-anchor="middle" font-family="Manrope,sans-serif" font-size="9" fill="#6b6a65">18650 Li</text>
      <text x="340" y="235" font-family="Manrope,sans-serif" font-size="10" fill="#6b6a65">capacity (mAh) per cell — more is longer runtime</text>
      <rect x="340" y="248" width="260" height="34" rx="3" fill="#edeae0" stroke="#c4bfb0" stroke-width="1"/>
      <text x="350" y="263" font-family="IBM Plex Mono,monospace" font-size="10" fill="#3d3c38">2000mAh ÷ 400mA load = 5h runtime</text>
      <text x="350" y="278" font-family="Manrope,sans-serif" font-size="10" fill="#6b6a65">estimate only — voltage sag cuts this by ~30%</text>
    </svg>

Fig 3.2: Four AA cells in series: voltages add (1.5×4 = 6V), capacity stays the same as one cell. Capacity comparison by chemistry: a good alkaline AA at 2,000mAh will run a lightly loaded robot for 3–5 hours. NiMH rechargeables are the smarter long-term choice despite slightly lower initial voltage (1.2V each = 4.8V total).

One practical note on NiMH cells: they output 1.2V each rather than 1.5V, so four in series gives 4.8V rather than 6V. The L298N motor driver and Arduino both work fine at 4.8V, but your motors will be about 20% slower. That trade is usually worth it: you can recharge NiMH hundreds of times, and you will go through a lot of batteries during this course.

Battery care. Always use four cells of the same type and age. Do not mix alkaline with NiMH, and do not mix fresh cells with partially drained ones. Mismatched cells cause uneven discharge, which shortens runtime and can leak. If the robot will sit unused for more than a week, remove the batteries. Alkaline cells left in a holder for months can corrode the contacts.


3.3 The L298N motor driver

The L298N is an H-bridge driver. "H-bridge" describes the circuit topology: four transistor switches arranged in an H shape around the motor. By opening and closing different pairs of switches, you can push current through the motor in either direction: forward, backward, or stop. The Arduino controls which switches are open using digital pins, without ever having to handle the motor's current directly.

<svg viewBox="0 0 760 340" width="100%" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <marker id="aR" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M2 2L8 5L2 8" fill="none" stroke="#c8420a" stroke-width="1.5" stroke-linecap="round"/></marker>
        <marker id="aG2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M2 2L8 5L2 8" fill="none" stroke="#1a6b4a" stroke-width="1.5" stroke-linecap="round"/></marker>
        <marker id="aY" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M2 2L8 5L2 8" fill="none" stroke="#c8b400" stroke-width="1.5" stroke-linecap="round"/></marker>
      </defs>

      <!-- L298N PCB body -->
      <rect x="260" y="60" width="240" height="220" rx="6" fill="#1f3f80" stroke="#3060c0" stroke-width="1.5"/>
      <!-- heatsink -->
      <rect x="270" y="60" width="220" height="16" rx="2" fill="#333"/>
      <line x1="295" y1="60" x2="295" y2="76" stroke="#555" stroke-width="1.5"/>
      <line x1="320" y1="60" x2="320" y2="76" stroke="#555" stroke-width="1.5"/>
      <line x1="345" y1="60" x2="345" y2="76" stroke="#555" stroke-width="1.5"/>
      <line x1="370" y1="60" x2="370" y2="76" stroke="#555" stroke-width="1.5"/>
      <line x1="395" y1="60" x2="395" y2="76" stroke="#555" stroke-width="1.5"/>
      <line x1="420" y1="60" x2="420" y2="76" stroke="#555" stroke-width="1.5"/>
      <line x1="445" y1="60" x2="445" y2="76" stroke="#555" stroke-width="1.5"/>
      <!-- L298N chip -->
      <rect x="310" y="130" width="140" height="80" rx="3" fill="#111"/>
      <text x="380" y="175" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="12" fill="#3060c0">L298N</text>

      <!-- LEFT screw terminals: motor A -->
      <rect x="240" y="100" width="22" height="60" rx="2" fill="#333" stroke="#555" stroke-width="1"/>
      <rect x="244" y="108" width="14" height="12" rx="1" fill="#c8420a" opacity=".8"/>
      <rect x="244" y="130" width="14" height="12" rx="1" fill="#1a1a18" opacity=".8"/>
      <text x="234" y="118" text-anchor="end" font-family="IBM Plex Mono,monospace" font-size="9" fill="#c8420a">OUT1</text>
      <text x="234" y="146" text-anchor="end" font-family="IBM Plex Mono,monospace" font-size="9" fill="#888">OUT2</text>
      <text x="234" y="165" text-anchor="end" font-family="Manrope,sans-serif" font-size="10" fill="#555">Motor A</text>

      <!-- RIGHT screw terminals: motor B -->
      <rect x="498" y="100" width="22" height="60" rx="2" fill="#333" stroke="#555" stroke-width="1"/>
      <rect x="502" y="108" width="14" height="12" rx="1" fill="#c8420a" opacity=".8"/>
      <rect x="502" y="130" width="14" height="12" rx="1" fill="#1a1a18" opacity=".8"/>
      <text x="526" y="118" font-family="IBM Plex Mono,monospace" font-size="9" fill="#c8420a">OUT3</text>
      <text x="526" y="146" font-family="IBM Plex Mono,monospace" font-size="9" fill="#888">OUT4</text>
      <text x="526" y="165" font-family="Manrope,sans-serif" font-size="10" fill="#555">Motor B</text>

      <!-- BOTTOM pin row: logic + power -->
      <rect x="280" y="290" width="200" height="18" rx="2" fill="#222"/>
      <g fill="#c8b400">
        <circle cx="295" cy="299" r="4"/><circle cx="318" cy="299" r="4"/>
        <circle cx="341" cy="299" r="4"/><circle cx="364" cy="299" r="4"/>
        <circle cx="387" cy="299" r="4"/><circle cx="410" cy="299" r="4"/>
        <circle cx="433" cy="299" r="4"/><circle cx="456" cy="299" r="4"/>
      </g>
      <text x="295" y="322" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">IN1</text>
      <text x="318" y="322" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">IN2</text>
      <text x="341" y="322" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">ENA</text>
      <text x="364" y="322" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="8" fill="#c8420a">12V</text>
      <text x="387" y="322" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="8" fill="#1a6b4a">GND</text>
      <text x="410" y="322" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">ENB</text>
      <text x="433" y="322" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">IN3</text>
      <text x="456" y="322" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">IN4</text>

      <!-- Wiring guide on right -->
      <text x="570" y="66" font-family="IBM Plex Mono,monospace" font-size="11" font-weight="500" fill="#f5f2eb">Pin guide</text>
      <line x1="570" y1="72" x2="740" y2="72" stroke="#333" stroke-width="1"/>
      <text x="570" y="90" font-family="IBM Plex Mono,monospace" font-size="9" fill="#c8420a">12V →</text>
      <text x="610" y="90" font-family="Manrope,sans-serif" font-size="10" fill="#888">battery + (6V ok)</text>
      <text x="570" y="108" font-family="IBM Plex Mono,monospace" font-size="9" fill="#1a6b4a">GND →</text>
      <text x="610" y="108" font-family="Manrope,sans-serif" font-size="10" fill="#888">battery − AND Arduino GND</text>
      <text x="570" y="126" font-family="IBM Plex Mono,monospace" font-size="9" fill="#c8b400">ENA →</text>
      <text x="610" y="126" font-family="Manrope,sans-serif" font-size="10" fill="#888">PWM pin (speed, motor A)</text>
      <text x="570" y="144" font-family="IBM Plex Mono,monospace" font-size="9" fill="#c8b400">ENB →</text>
      <text x="610" y="144" font-family="Manrope,sans-serif" font-size="10" fill="#888">PWM pin (speed, motor B)</text>
      <text x="570" y="162" font-family="IBM Plex Mono,monospace" font-size="9" fill="#888">IN1/IN2→</text>
      <text x="622" y="162" font-family="Manrope,sans-serif" font-size="10" fill="#888">direction, motor A</text>
      <text x="570" y="180" font-family="IBM Plex Mono,monospace" font-size="9" fill="#888">IN3/IN4→</text>
      <text x="622" y="180" font-family="Manrope,sans-serif" font-size="10" fill="#888">direction, motor B</text>
      <line x1="570" y1="192" x2="740" y2="192" stroke="#333" stroke-width="1"/>
      <text x="570" y="210" font-family="IBM Plex Mono,monospace" font-size="9" fill="#c8420a">OUT1/2 →</text>
      <text x="627" y="210" font-family="Manrope,sans-serif" font-size="10" fill="#888">left motor wires</text>
      <text x="570" y="228" font-family="IBM Plex Mono,monospace" font-size="9" fill="#c8420a">OUT3/4 →</text>
      <text x="627" y="228" font-family="Manrope,sans-serif" font-size="10" fill="#888">right motor wires</text>
      <line x1="570" y1="240" x2="740" y2="240" stroke="#333" stroke-width="1"/>
      <text x="570" y="258" font-family="Manrope,sans-serif" font-size="10" fill="#c8b400">Ground rule:</text>
      <text x="570" y="274" font-family="Manrope,sans-serif" font-size="10" fill="#666">Arduino GND and battery</text>
      <text x="570" y="290" font-family="Manrope,sans-serif" font-size="10" fill="#666">GND must share one wire.</text>
      <text x="570" y="306" font-family="Manrope,sans-serif" font-size="10" fill="#666">Without this, logic signals</text>
      <text x="570" y="322" font-family="Manrope,sans-serif" font-size="10" fill="#666">have no reference — robot</text>
      <text x="570" y="338" font-family="Manrope,sans-serif" font-size="10" fill="#c8420a">behaves randomly.</text>
    </svg>

Fig 3.3: L298N motor driver pinout. Six logic pins go to the Arduino (IN1–IN4 for direction, ENA/ENB for speed via PWM). Two screw terminal pairs go to the motors. Power enters via the 12V and GND terminals. The single most important wiring rule: the Arduino GND and battery GND must be connected together. A shared ground reference is what makes all the signal voltages make sense.

Heat warning. The L298N heatsink gets hot during operation, reaching 60-70C during sustained turns. This is normal and will not damage the module, but avoid touching the metal fin while the robot is running or immediately after.

Orienting the L298N board. Before reading the pin labels, locate the large blue electrolytic capacitor on the board. It sits near the power input terminals. On most modules the capacitor is at the corner closest to the 12V and GND input screw terminals, with the heatsink fin at the opposite end. Use these landmarks — capacitor at the power end, heatsink at the control end — to orient the board before identifying individual pins.

Arduino GND and battery GND must share one wire. Without a common ground, every signal the Arduino sends to the motor driver is referenced to a different zero point and the robot behaves unpredictably. This is the number-one wiring mistake on first builds.


3.4 Breadboard layout rules

The breadboard lets you make temporary connections without soldering. Understanding its internal connection pattern is not optional: plug wires into the wrong rails and nothing works, and the failure is completely invisible from the outside.

<svg viewBox="0 0 760 260" width="100%" xmlns="http://www.w3.org/2000/svg">
      <!-- breadboard body -->
      <rect x="40" y="40" width="500" height="200" rx="8" fill="#f0ede4" stroke="#c4bfb0" stroke-width="2"/>
      <!-- center groove -->
      <rect x="40" y="134" width="500" height="12" rx="0" fill="#d8d4c8"/>
      <!-- top power rails -->
      <rect x="50" y="50" width="480" height="14" rx="3" fill="#fde8e8"/>
      <rect x="50" y="66" width="480" height="14" rx="3" fill="#e8f0fe"/>
      <!-- bottom power rails -->
      <rect x="50" y="186" width="480" height="14" rx="3" fill="#fde8e8"/>
      <rect x="50" y="202" width="480" height="14" rx="3" fill="#e8f0fe"/>
      <!-- top terminal strips: 5 rows -->
      <rect x="50" y="88" width="480" height="10" rx="2" fill="#edeae0"/>
      <rect x="50" y="100" width="480" height="10" rx="2" fill="#edeae0"/>
      <rect x="50" y="112" width="480" height="10" rx="2" fill="#edeae0"/>
      <rect x="50" y="124" width="480" height="10" rx="2" fill="#edeae0"/>
      <!-- bottom terminal strips: 5 rows -->
      <rect x="50" y="148" width="480" height="10" rx="2" fill="#edeae0"/>
      <rect x="50" y="160" width="480" height="10" rx="2" fill="#edeae0"/>
      <rect x="50" y="172" width="480" height="10" rx="2" fill="#edeae0"/>
      <rect x="50" y="182" width="480" height="10" rx="2" fill="#edeae0"/>

      <!-- Pin holes top power rail + -->
      <g fill="#c8420a">
        <circle cx="68" cy="57" r="3"/><circle cx="82" cy="57" r="3"/><circle cx="96" cy="57" r="3"/>
        <circle cx="110" cy="57" r="3"/><circle cx="124" cy="57" r="3"/><circle cx="138" cy="57" r="3"/>
        <circle cx="152" cy="57" r="3"/><circle cx="166" cy="57" r="3"/><circle cx="180" cy="57" r="3"/>
        <circle cx="194" cy="57" r="3"/><circle cx="208" cy="57" r="3"/>
      </g>
      <text x="540" y="60" font-family="IBM Plex Mono,monospace" font-size="10" fill="#c8420a">+ rail (all connected)</text>
      <text x="540" y="76" font-family="IBM Plex Mono,monospace" font-size="10" fill="#1f4d8c">− rail (all connected)</text>
      <line x1="68" y1="57" x2="510" y2="57" stroke="#c8420a" stroke-width="1" stroke-dasharray="4 2" opacity=".5"/>
      <line x1="68" y1="73" x2="510" y2="73" stroke="#1f4d8c" stroke-width="1" stroke-dasharray="4 2" opacity=".5"/>

      <!-- Terminal strip connection arrows (vertical within column) -->
      <line x1="80" y1="88" x2="80" y2="134" stroke="#1a6b4a" stroke-width="2" opacity=".6"/>
      <text x="82" y="86" font-family="Manrope,sans-serif" font-size="10" fill="#1a6b4a">col A–E</text>
      <text x="82" y="97" font-family="Manrope,sans-serif" font-size="10" fill="#6b6a65">connected</text>
      <text x="82" y="108" font-family="Manrope,sans-serif" font-size="10" fill="#6b6a65">vertically</text>

      <!-- NOT connected across center gap -->
      <text x="250" y="142" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="10" fill="#c8420a">— center gap — NOT connected —</text>

      <line x1="80" y1="148" x2="80" y2="182" stroke="#1a6b4a" stroke-width="2" opacity=".6"/>
      <text x="82" y="147" font-family="Manrope,sans-serif" font-size="10" fill="#1a6b4a">col F–J</text>
      <text x="82" y="158" font-family="Manrope,sans-serif" font-size="10" fill="#6b6a65">connected</text>
      <text x="82" y="169" font-family="Manrope,sans-serif" font-size="10" fill="#6b6a65">vertically</text>

      <!-- bottom power rail labels -->
      <text x="540" y="196" font-family="IBM Plex Mono,monospace" font-size="10" fill="#c8420a">+ rail</text>
      <text x="540" y="212" font-family="IBM Plex Mono,monospace" font-size="10" fill="#1f4d8c">− rail</text>

      <!-- rule box -->
      <rect x="560" y="90" width="180" height="80" rx="4" fill="#1a1a18"/>
      <text x="650" y="110" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="10" fill="#888">3 rules</text>
      <text x="570" y="128" font-family="Manrope,sans-serif" font-size="11" fill="#c8c4bc">1. Rows don't cross gap</text>
      <text x="570" y="144" font-family="Manrope,sans-serif" font-size="11" fill="#c8c4bc">2. Power rails run long</text>
      <text x="570" y="160" font-family="Manrope,sans-serif" font-size="11" fill="#c8c4bc">3. IC straddles center</text>
    </svg>

Fig 3.4: Breadboard internal connections. The two long rails at top and bottom carry + and − power along the full length. The terminal strips in the middle connect five holes in a column (a–e and f–j), but the center gap isolates the two halves. IC chips straddle the center gap so each pin has its own five-hole group to connect to.

Three rules, committed to memory: power rails run the full length of the board, so plug power in at one end and the whole rail is live. Terminal strips connect five holes vertically in each column, stopping at the center gap. The two halves of the board are completely isolated from each other across that gap. An integrated circuit plugged across the gap gets five independent connection points per pin. That is the point of the gap.


Polarity check. Before connecting the battery for the first time, double-check that the red wire goes to the + terminal and the black wire goes to the - terminal on the L298N. A reversed battery can permanently damage the motor driver or Arduino. Check twice, connect once.

3.5 The full robot wiring diagram

Every connection for the complete robot is shown below. Study it before you wire anything. The color coding matches the physical wire colors you should use: red for positive power, black for ground, blue for logic signals, and orange for motor outputs. Using consistent wire colors is not cosmetic. It makes faults visible at a glance when you are debugging at 11pm.

<svg viewBox="0 0 760 420" width="100%" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <marker id="aRed" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M2 2L8 5L2 8" fill="none" stroke="#c8420a" stroke-width="1.5" stroke-linecap="round"/></marker>
        <marker id="aGrn" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M2 2L8 5L2 8" fill="none" stroke="#1a6b4a" stroke-width="1.5" stroke-linecap="round"/></marker>
        <marker id="aBlu2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M2 2L8 5L2 8" fill="none" stroke="#4090e0" stroke-width="1.5" stroke-linecap="round"/></marker>
        <marker id="aOrg" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M2 2L8 5L2 8" fill="none" stroke="#e07020" stroke-width="1.5" stroke-linecap="round"/></marker>
      </defs>

      <!-- BATTERY PACK -->
      <rect x="30" y="170" width="90" height="60" rx="4" fill="#5a5000" stroke="#c8b400" stroke-width="1.5"/>
      <text x="75" y="196" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#f5e060">BATTERY</text>
      <text x="75" y="210" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#f5e060">4×AA 6V</text>
      <circle cx="40" cy="170" r="5" fill="#c8420a"/>
      <circle cx="110" cy="170" r="5" fill="#444"/>
      <text x="40" y="162" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#c8420a">+</text>
      <text x="110" y="162" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#888">−</text>

      <!-- L298N DRIVER -->
      <rect x="200" y="140" width="160" height="140" rx="5" fill="#1f3f80" stroke="#3060c0" stroke-width="1.5"/>
      <text x="280" y="168" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" fill="#a0c0f0">L298N</text>
      <text x="280" y="184" text-anchor="middle" font-family="Manrope,sans-serif" font-size="10" fill="#7090c0">motor driver</text>
      <rect x="184" y="158" width="18" height="44" rx="2" fill="#333"/>
      <text x="176" y="175" text-anchor="end" font-family="IBM Plex Mono,monospace" font-size="8" fill="#e07020">OUT1</text>
      <text x="176" y="195" text-anchor="end" font-family="IBM Plex Mono,monospace" font-size="8" fill="#e07020">OUT2</text>
      <rect x="358" y="158" width="18" height="44" rx="2" fill="#333"/>
      <text x="380" y="175" font-family="IBM Plex Mono,monospace" font-size="8" fill="#e07020">OUT3</text>
      <text x="380" y="195" font-family="IBM Plex Mono,monospace" font-size="8" fill="#e07020">OUT4</text>
      <g fill="#c8b400">
        <circle cx="220" cy="286" r="4"/><circle cx="236" cy="286" r="4"/>
        <circle cx="252" cy="286" r="4"/><circle cx="268" cy="286" r="4"/>
        <circle cx="284" cy="286" r="4"/><circle cx="300" cy="286" r="4"/>
        <circle cx="316" cy="286" r="4"/><circle cx="332" cy="286" r="4"/>
      </g>
      <text x="220" y="302" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#888">IN1</text>
      <text x="236" y="302" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#888">IN2</text>
      <text x="252" y="302" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#c8b400">ENA</text>
      <text x="268" y="302" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#c8420a">PWR</text>
      <text x="284" y="302" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#1a6b4a">GND</text>
      <text x="300" y="302" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#c8b400">ENB</text>
      <text x="316" y="302" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#888">IN3</text>
      <text x="332" y="302" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#888">IN4</text>

      <!-- ARDUINO UNO -->
      <rect x="440" y="80" width="150" height="260" rx="5" fill="#1a6b4a" stroke="#0e4030" stroke-width="1.5"/>
      <text x="515" y="108" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="11" fill="#a8e8c8">ARDUINO</text>
      <text x="515" y="124" text-anchor="middle" font-family="Manrope,sans-serif" font-size="10" fill="#60b080">UNO</text>
      <g fill="#c8b400">
        <circle cx="590" cy="150" r="4"/><circle cx="590" cy="168" r="4"/>
        <circle cx="590" cy="186" r="4"/><circle cx="590" cy="204" r="4"/>
        <circle cx="590" cy="222" r="4"/><circle cx="590" cy="240" r="4"/>
      </g>
      <text x="596" y="154" font-family="IBM Plex Mono,monospace" font-size="8" fill="#c8b400">D5 (ENA)</text>
      <text x="596" y="172" font-family="IBM Plex Mono,monospace" font-size="8" fill="#c8b400">D6 (ENB)</text>
      <text x="596" y="190" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">D7 (IN1)</text>
      <text x="596" y="208" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">D8 (IN2)</text>
      <text x="596" y="226" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">D9 (IN3)</text>
      <text x="596" y="244" font-family="IBM Plex Mono,monospace" font-size="8" fill="#888">D10 (IN4)</text>
      <circle cx="590" cy="300" r="4" fill="#1a6b4a" stroke="#a8e8c8" stroke-width="1.5"/>
      <text x="596" y="304" font-family="IBM Plex Mono,monospace" font-size="8" fill="#1a6b4a">GND</text>
      <circle cx="440" cy="300" r="4" fill="#c8420a"/>
      <text x="415" y="304" text-anchor="end" font-family="IBM Plex Mono,monospace" font-size="8" fill="#c8420a">Vin</text>

      <!-- MOTORS -->
      <rect x="30" y="290" width="80" height="50" rx="4" fill="#2a2a24" stroke="#555" stroke-width="1.5"/>
      <text x="70" y="314" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#aaa">MOTOR L</text>
      <circle cx="40" cy="290" r="4" fill="#c8420a"/>
      <circle cx="100" cy="290" r="4" fill="#888"/>
      <rect x="640" y="290" width="80" height="50" rx="4" fill="#2a2a24" stroke="#555" stroke-width="1.5"/>
      <text x="680" y="314" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#aaa">MOTOR R</text>
      <circle cx="650" cy="290" r="4" fill="#c8420a"/>
      <circle cx="710" cy="290" r="4" fill="#888"/>

      <!-- HC-SR04 SENSOR -->
      <rect x="620" y="30" width="110" height="50" rx="4" fill="#d8d4c8" stroke="#b0aba0" stroke-width="1.5"/>
      <text x="675" y="52" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="9" fill="#3d3c38">HC-SR04</text>
      <circle cx="635" cy="40" r="5" fill="none" stroke="#6b6a65" stroke-width="1.5"/><circle cx="635" cy="40" r="2" fill="#6b6a65"/>
      <circle cx="715" cy="40" r="5" fill="none" stroke="#6b6a65" stroke-width="1.5"/><circle cx="715" cy="40" r="2" fill="#6b6a65"/>
      <g fill="#c8b400">
        <circle cx="635" cy="72" r="3"/><circle cx="651" cy="72" r="3"/>
        <circle cx="667" cy="72" r="3"/><circle cx="683" cy="72" r="3"/>
      </g>
      <text x="635" y="84" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#c8420a">VCC</text>
      <text x="651" y="84" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#888">TRIG</text>
      <text x="667" y="84" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#888">ECHO</text>
      <text x="683" y="84" text-anchor="middle" font-family="IBM Plex Mono,monospace" font-size="7" fill="#1a6b4a">GND</text>

      <!-- WIRES -->
      <path d="M40 165 L40 130 L268 130 L268 286" fill="none" stroke="#c8420a" stroke-width="1.5" marker-end="url(#aRed)"/>
      <path d="M40 165 L40 130 L440 130 L440 296" fill="none" stroke="#c8420a" stroke-width="1.5" opacity=".6"/>
      <path d="M110 165 L110 318 L284 318 L284 286" fill="none" stroke="#444" stroke-width="1.5" stroke-dasharray="4 2" marker-end="url(#aGrn)"/>
      <path d="M110 165 L110 318 L590 318 L590 305" fill="none" stroke="#444" stroke-width="1.5" stroke-dasharray="4 2"/>
      <path d="M590 150 L615 150 L615 380 L252 380 L252 286" fill="none" stroke="#4090e0" stroke-width="1" marker-end="url(#aBlu2)"/>
      <path d="M590 168 L618 168 L618 384 L300 384 L300 286" fill="none" stroke="#4090e0" stroke-width="1" marker-end="url(#aBlu2)" opacity=".7"/>
      <path d="M590 186 L621 186 L621 388 L220 388 L220 286" fill="none" stroke="#6090c0" stroke-width="1" marker-end="url(#aBlu2)" opacity=".5"/>
      <path d="M184 168 L130 168 L130 286" fill="none" stroke="#e07020" stroke-width="1.5" marker-end="url(#aOrg)"/>
      <path d="M184 188 L120 188 L120 286 L40 286" fill="none" stroke="#e07020" stroke-width="1.5" marker-end="url(#aOrg)" opacity=".7"/>
      <path d="M376 168 L500 168 L500 390 L650 390 L650 340" fill="none" stroke="#e07020" stroke-width="1.5" marker-end="url(#aOrg)"/>
      <path d="M635 72 L635 60 L460 60 L460 80" fill="none" stroke="#c8420a" stroke-width="1" marker-end="url(#aRed)" opacity=".6"/>
      <path d="M683 72 L683 60" fill="none" stroke="#444" stroke-width="1" opacity=".6"/>

      <!-- Legend -->
      <rect x="30" y="370" width="280" height="42" rx="3" fill="#111"/>
      <circle cx="50" cy="382" r="4" fill="#c8420a"/><text x="60" y="386" font-family="Manrope,sans-serif" font-size="10" fill="#888">power (+)</text>
      <circle cx="110" cy="382" r="4" fill="#444"/><text x="120" y="386" font-family="Manrope,sans-serif" font-size="10" fill="#888">ground (−)</text>
      <circle cx="178" cy="382" r="4" fill="#4090e0"/><text x="188" y="386" font-family="Manrope,sans-serif" font-size="10" fill="#888">logic signal</text>
      <circle cx="254" cy="382" r="4" fill="#e07020"/><text x="264" y="386" font-family="Manrope,sans-serif" font-size="10" fill="#888">motor output</text>
    </svg>

Fig 3.5: Full robot wiring diagram. Red: power positive. Dark dashed: ground (shared between battery and Arduino; this connection is mandatory). Blue: logic signals from Arduino to motor driver. Orange: motor output from driver to motors. Sensor VCC taps from Arduino 5V pin. Every ground in this diagram connects back to the same common point.


Lab 03: Wire the motor driver: one motor spins, no smoke

No Arduino code yet. You will wire the battery, L298N, and one motor, then verify the motor spins when you connect the battery. This tests your wiring before adding the complexity of code.

What you need

Assembled chassis from Module 02 · L298N motor driver · Battery holder with charged cells · Full-size breadboard (830 tie points; the larger board gives enough room for the L298N and connections without crowding) · Jumper wires, 22AWG or heavier for battery and motor connections (red, black, and at least 4 other colors) · Multimeter (if available)

Instructor note If your chassis is metal or aluminum, place a strip of electrical tape under any circuit board or breadboard that overhangs the chassis surface. Metal chassis create a conductive plane; a loose wire or exposed component lead touching the chassis can short circuit and damage components.

Instructor note Secure the breadboard to the chassis before wiring. Most breadboards have adhesive backing; peel the protective film and press firmly onto the chassis surface. If your breadboard has no adhesive, a strip of double-sided foam tape works well. A breadboard that shifts during driving disconnects wires at the worst moment.

Instructor note Mount the battery holder centered between the two drive wheels, symmetric left-to-right. The loaded battery pack weighs roughly 90g, which is significant at this scale. An off-center battery tilts the robot's weight distribution, which you will later try to correct with motor trim constants. Start level.

Safety note (metal chassis): If your chassis plate is metal or aluminium, place a strip of electrical tape or foam tape under every circuit board and the breadboard before mounting. Bare component leads touching a conductive chassis can short-circuit and destroy components.

Wire routing: Route all wires above the chassis top surface and keep a minimum 30 mm clearance from both drive wheel positions. Wires that hang below the chassis or pass near wheel paths will catch in the spinning wheels; this is the most common cause of mid-drive failures.

  1. Disconnect the battery completely before touching any wires. Keep it disconnected until step 9.
  2. Mount the L298N on the chassis or breadboard. Locate the PWR, GND, OUT1, and OUT2 terminals. Mount it with the chip body facing upward and clear of other components; keep flammable or foam materials at least 2 cm from the chip body, as it reaches 60–70 °C during extended pivot turns.
  3. Run a red wire from battery + to the L298N PWR terminal. Run a black wire from battery − to the L298N GND terminal. Do not connect battery yet.
  4. Run a wire from OUT1 to the positive (red-marked) lead of the left motor. Run a wire from OUT2 to the motor's other lead.
  5. Locate the IN1 and IN2 pins on the L298N. Bridge IN1 to the PWR terminal with a short jumper wire. This sets motor direction to forward.
  6. Bridge IN2 to GND with a short jumper wire. This completes the direction logic for channel A.
  7. Bridge ENA to PWR (or the 5V rail if available). This enables the channel at full speed.
  8. Visually trace every wire end-to-end before connecting power. Red leads to PWR. Black leads to GND. Common ground is present. No bare wire ends are touching anything they should not touch.
  9. Connect the battery. The motor should spin. If it does not spin, check ENA first. If it spins backward, swap OUT1 and OUT2 at the screw terminals.
  10. If you have a multimeter: set it to DC volts, black probe to GND, red probe to the OUT1 terminal. With the motor spinning you should see roughly the battery voltage. If you read zero, IN1/IN2 logic is wrong.

Module milestone One motor spins on bench power from the battery through the L298N, no code, no smoke. When it does, disconnect power and move to Module 4.

Safety note (USB and battery together): When uploading new code, disconnect the battery pack first. The L298N's onboard 5V regulator feeds the Arduino's 5V pin directly, bypassing the USB port's protective fuse. With both connected, the battery can backfeed into the USB circuit. This is unlikely to cause damage at 6V from AA cells, but it is good practice to keep the two power paths separate: battery for driving, USB for uploading and Serial Monitor. If you want Serial Monitor while the robot drives, leave USB connected but do not run the motors from USB power alone.


Self-Check: Module 3

Key Terms Glossary

Term Definition
voltage (V) Electrical potential difference between two points. The battery's voltage is what pushes current through a circuit. Measured in volts.
current (A) The rate of charge flow through a conductor. Motors draw current. Too much current through a component destroys it. Measured in amps (A) or milliamps (mA).
mAh Milliamp-hours. Battery capacity unit. A 2,000mAh battery can supply 200mA for 10 hours, or 1,000mA for 2 hours. Product of current × time.
H-bridge A circuit of four switches arranged so current can be pushed through a motor in either direction. The L298N contains two H-bridges, one per motor channel.
common ground The shared reference point connecting battery negative to Arduino GND. Without it, signal voltages have no consistent reference and the circuit misbehaves.
PWM pin A digital pin that can simulate variable voltage by switching on and off very rapidly. Used on ENA/ENB to control motor speed. Only certain Arduino pins support this (marked ~).
stall current The current a motor draws when held stationary against a load. Much higher than running current, often 5–8× higher. Relevant for choosing wire gauge and fuse ratings.
Ohm's Law V = I × R. Voltage equals current times resistance. Know any two values and you can calculate the third. The foundation of all circuit analysis.

Previous: ← Module 02: Chassis & Drivetrain Assembly · Next: Module 04: Your First Arduino Sketch →

Related Blog Posts