> For the complete documentation index, see [llms.txt](https://docs.protoboard.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.protoboard.xyz/tutorials/line-following-robot.md).

# Build a line-following robot

Build the drive train of a line-following robot from library parts, connect power and motor control, organize the canvas and get a clean DRC

## Goal

Build the **Main controller** board of the Line-Following Robot demo project by hand: an Arduino Nano, an L298N motor driver, two gearmotors and a 12 V battery. You'll connect power and control, group the motors, leave a note for your team and finish with a clean DRC. Every other tutorial uses this project.

{% hint style="info" %}
**Time:** 15 to 20 minutes. **You need:** a free account. If you haven't used the editor yet, do the [Quickstart](/start-here/quickstart-10-minutes.md) first.
{% endhint %}

## What you're building

| Part               | Role                                                          |
| ------------------ | ------------------------------------------------------------- |
| Arduino Nano       | Controller: reads the line sensor and drives the motors       |
| L298N motor driver | Switches battery power to the motors under the Nano's control |
| 2 × N20 gearmotors | Left and right wheels                                         |
| 12 V battery       | Powers the motor driver                                       |

The line sensor comes later: in [Design with ProtoBot](/tutorials/design-with-protobot.md), ProtoBot adds an IR sensor array to this board.

<figure><picture><source srcset="https://3535233690-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHc6ZGiGpKHrs578383AS%2Fuploads%2Fgit-blob-6231d48019be2d375d471619ad4919e2ca7cf418%2Feditor-overview-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://3535233690-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHc6ZGiGpKHrs578383AS%2Fuploads%2Fgit-blob-36c2d6da726c875719bfc7cb6a2f8829d99acba4%2Feditor-overview-light.png?alt=media" alt="The finished Main controller board: Arduino Nano, L298N motor driver, two N20 gearmotors in a group labelled Drive motors, a 12 V battery and a note linked to the motor driver"></picture><figcaption><p>The finished Main controller board.</p></figcaption></figure>

## Steps

{% stepper %}
{% step %}

### Create the project and the board

1. On Home, click **+** next to **PROJECTS**, name the project `Line-Following Robot` and click **Create**.
2. Open the project from the sidebar and click **New Board**.
3. Name the board `Main controller` and click **Create board**.
   {% endstep %}

{% step %}

### Add the parts

Open **Parts Bin** in the left rail and add each part with its **Add** button:

1. Search `arduino nano` and add the Arduino Nano.
2. Search `L298N` and add the L298N motor driver.
3. Search `N20 gearmotor` and add it. Right-click the motor and choose **Duplicate** to make the second one.
4. Search `12V battery` and add a battery.

Parts land in free space near the middle of the canvas. Drag them into a rough left-to-right layout: battery, driver, motors on one side, Nano on the other.

{% hint style="info" %}
Can't find a part? Click **Can't find it? Request a part** under the search results. See [Request or fix a part](/parts/request-or-fix-a-part.md).
{% endhint %}
{% endstep %}

{% step %}

### Connect the battery to the driver

1. Drag from the battery's edge handle to the L298N.
2. In the Inspector, open **Interface pair** and choose the power pair.
3. Rename the harness `12V motor supply` in the harness name field.
   {% endstep %}

{% step %}

### Connect the driver to each motor

1. Drag from the L298N to the left motor and choose the motor output pair.
2. Rename it `Left motor drive`.
3. Repeat for the right motor and name it `Right motor drive`.

The L298N has two motor channels. If you connect a third motor, the DRC reports that the interface is over capacity.
{% endstep %}

{% step %}

### Connect the Nano to the driver

1. Drag from the Arduino Nano to the L298N and choose the control pair for one channel. Name it `Left motor control`.
2. Create a second harness for the other channel and name it `Right motor control`.
3. If a harness stays amber, open **Function Links** in the Inspector and click **Auto Assign**, or pick pins in each row. See [Resource allocation](/editor/resource-allocation.md).
   {% endstep %}

{% step %}

### Group the motors

{% embed url="<https://cdn.protoboard.ai/docs/clip/group-selection?title=Group+selected+parts>" %}
Group selected parts
{% endembed %}

[Animated GIF](https://cdn.protoboard.ai/docs/clips/group-selection-light.gif) · Steps:

1. Drag a box around both motors (with nothing selected, dragging the canvas box-selects).
2. Click **Add group** in the canvas toolbar. The group wraps the selection.
3. In the Inspector, name the group `Drive motors` and pick a colour.
   {% endstep %}

{% step %}

### Leave a note for the team

{% embed url="<https://cdn.protoboard.ai/docs/clip/note-add?title=Add+a+note+and+connect+it>" %}
Add a note and connect it
{% endembed %}

[Animated GIF](https://cdn.protoboard.ai/docs/clips/note-add-light.gif) · Steps:

1. Click **Add note** in the canvas toolbar. The note lands in free space.
2. Type `Check the L298N heat sink at stall current`.
3. With the note selected, use **Connect annotation** in the Inspector and choose the L298N, then click **Create**.
   {% endstep %}

{% step %}

### Check the DRC

1. Open **Board Review**. Fix anything under **BLOCKED** first, then **PARTIAL**.
2. Expand an issue and click the target icon to jump to it.
3. When **// DRC Issues** reads "No DRC issues found", every harness is configured.

See [Fixing DRC failures](/validate-and-build/fixing-drc-failures.md) if an issue doesn't clear.
{% endstep %}

{% step %}

### Describe the board

1. Open **Board Identity** in the left rail.
2. Add a description, the tags `robotics` and `line-follower`, and a requirement such as `Runs 30 minutes on one charge`.

ProtoBot and your teammates read this when they work on the board. See [Board Identity, requirements and kits](/editor/board-identity.md).
{% endstep %}
{% endstepper %}

## Result

You have a validated drive train with named harnesses, a group and a note. Next, [let ProtoBot add the line sensor](/tutorials/design-with-protobot.md), or [price the BOM](/tutorials/price-and-order-your-bom.md).

## Common failures

<details>

<summary>The motor harness is red: "No compatible interface pairs found"</summary>

You connected two parts that share no interface, for example the battery straight to a motor. Delete the harness and connect through the motor driver.

</details>

<details>

<summary>A control harness stays amber</summary>

Some functions have no pin assigned. The issue in Board Review names them ("Side A function ... not yet assigned to a resource"). Use **Auto Assign** or pick pins in **Function Links**.

</details>

<details>

<summary>Add group created an empty group</summary>

Nothing was selected. Select the parts first, then click **Add group**, or drag parts into the empty group.

</details>

## Related pages

* [Design with ProtoBot](/tutorials/design-with-protobot.md): add the IR sensor array with ProtoBot
* [Harnesses and function links](/editor/harnesses-and-function-links.md): what each harness holds
* [Groups and notes](/editor/groups-and-notes.md): organize larger boards
* [Share a project with your team](/tutorials/share-a-project.md): bring a teammate into the project
