Blog / How to Program a Line Tracing Robot: Your First Oracle Run

Line Tracing

How to Program a Line Tracing Robot: Your First Oracle Run

November 17, 2026 · 8 min read · Flouw Robotics

Your Oracle line tracing robot is out of the box. Now what? Most teams lose their first week to setup problems, a robot that steers away from the line, or a course that works once and never again.

This guide takes you from the box to your first full course on the track, step by step. It follows the Oracle student manual, and every command here comes straight from it.

TLDR

  • Safety first: battery off before USB, every time.
  • Setup: add the Motion 2350 Pro to Arduino IDE, install the Cytron Motor Drivers Library, upload the Oracle program.
  • Check, then calibrate: run the motor check, read the sensor with ShowRaw, then Calibrate on your own track.
  • First run: one flouw.Track line follows the line. Then build a course one junction at a time.
  • Tune: drifts = raise kp, wobbles = raise kd, twitches = lower kd. One change at a time.
Oracle line tracing robot, front view with the 16-channel sensor bar lit red

What you need

  • An Oracle Advanced Line Tracing Kit. It comes pre-assembled and pre-wired, so you skip the build and go straight to programming.
  • The kit's 850mAh 11.1V 3S LiPo battery, LiPo checker and charger (all in the box).
  • The programming cable from the kit and a laptop with Arduino IDE.
  • The Oracle program Flouw_PD_16CH.ino (comes with your kit's manual and code).
  • A track: a white mat with a black line, 90° corners, at least one cross and one T-junction.

Using the Oracle Basic? Its program, Flouw_PD_4Sens.ino, uses the same commands and the same logic. The steps below work the same way with 4 sensors instead of 16.

Step 1: The one safety rule

Battery off before USB. Powering the board from USB and the LiPo at the same time can damage the board, and even your laptop. Check the battery with the LiPo checker before every session: 10.5V or less means stop and charge. Never charge a LiPo unattended.

The Oracle's 1680rpm motors are fast. Test motors with the wheels off the table, and only run courses on the track.

Step 2: Set up Arduino IDE for the Motion 2350 Pro

The Oracle's brain is the Cytron Motion 2350 Pro. If your laptop is already set up from the Flouw EduKit, skip to step 4.

  1. Install Arduino IDE from arduino.cc.
  2. Go to File › Preferences. In Additional Boards Manager URLs, paste: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
  3. Open Tools › Board › Boards Manager, search "pico", and install Raspberry Pi Pico/RP2040/RP2350 by Earle F. Philhower, III. Then select Cytron Motion 2350 Pro as the board.
  4. Open Tools › Manage Libraries, search Cytron Motor Drivers Library, and install it.
  5. Put Flouw_PD_16CH.ino in a folder with the same name (Flouw_PD_16CH/Flouw_PD_16CH.ino). Arduino IDE needs the names to match.

Step 3: Upload in the safe order

  1. Battery out, USB in. Choose the port under Tools › Port and upload. Wait for "Done uploading".
  2. Unplug USB.
  3. Connect the battery, put the robot on a stand, switch power on.
  4. Press Button 1. The program starts.

Step 4: Check the motors

If a motor is on the wrong port or wired backwards, the robot steers away from the line. Check it once. Put this in Course1():

void Course1() {

flouw.Drive(80, 0); // TEST 1: only the LEFT wheel, forward

delay(1000);

flouw.Stop();

delay(1500);

flouw.Drive(0, 80); // TEST 2: only the RIGHT wheel, forward

delay(1000);

flouw.End();

}

  • Test 1 moves the right wheel: swap the motor plugs on M1 and M2.
  • A wheel turns backward: swap that motor's two wires.
  • Nothing moves: check the battery and power switch, then press Button 1.

Tip from our trainers: put a small piece of tape on the left wheel. It makes the two tests easy to see.

Step 5: Read the sensor bar with ShowRaw

The Oracle's sensor bar has 16 infrared sensors in a row, CH0 on the far left to CH15 on the far right. White reflects a lot of light and reads low (about 100 to 150). The black line reads high (up to 1023).

  1. In setup(), remove the // in front of flouw.ShowRaw(); and upload (battery out).
  2. Open the Serial Monitor at 115200 baud. You'll see 16 numbers per line.
  3. Slide the robot slowly across the line. The high numbers should move smoothly from the first column to the last.
  4. Press Button 1 to leave, and put the // back.

If one channel never changes, that sensor is dirty or blocked. Clean it. If the numbers jump around out of order, check the sensor bar's select wires.

Oracle line tracing robot on a white track mat, 16-channel sensor bar and Motion 2350 Pro board

Step 6: Calibrate on your own track

Every sensor, mat and room light is a little different. Calibration measures white and black for each channel, so the robot reads every channel from 0 (white) to 1000 (black).

  1. Uncomment flouw.Calibrate();, upload and open the Serial Monitor.
  2. Put the robot on the track with the sensor bar over the line. Press and release Button 1.
  3. For about 4 seconds, slide the robot left and right by hand so every channel passes over the line and the white.
  4. The Serial Monitor prints two lines, CAL_LO and CAL_HI. Paste them over the old ones, comment out Calibrate again and upload.

Check it with flouw.ShowCalibrated();: about 4 channels on the line should read 700 to 1000, and the rest near 0. Calibrate again whenever you change tracks, the light changes, or the sensor bar was moved.

Stuck on a step? Send us a photo of your Serial Monitor on Facebook. We'll help you read it, free. Every Oracle comes with free lifetime support.

Step 7: Your first run

Time to let it go. Put a straight line in front of the robot and use one command:

void Course1() {

flouw.Track(100, 0.15, 5.0, 3000); // follow the line for 3 seconds

flouw.End(); // stop

}

The four numbers in Track(speed, kp, kd, ms) are:

  • speed (0 to 255): how fast it drives.
  • kp (about 0.02 to 0.2): steering strength. Higher turns back to the line harder.
  • kd (about 0.05 to 5.0): steadiness. Higher means less wobbling, too high gets twitchy.
  • ms: how long, in milliseconds. 1000 is one second.

Then try a smooth start: flouw.Track(50, 150, 0.02, 0.05, 1000); ramps the speed from 50 to 150. Watch what changes.

Step 8: Write your first course

A course is a list of commands that describes the track, like giving directions. Here's the method:

  1. Draw the track and number every corner, cross and T-junction in the order the robot meets them.
  2. For each one, decide: left, right or straight. Always from the robot's point of view.
  3. Write one building block per junction.
  4. Test one block at a time: put flouw.End(); right after the part you're testing, then move it down.

The building blocks:

  • Left 90° corner: flouw.TrackLeft(60, 0.02, 0.05); then flouw.SwingLeft(150);
  • Right 90° corner: flouw.TrackRight(60, 0.02, 0.05); then flouw.SwingRight(120);
  • Cross, go straight: flouw.TrackCross(100, 0.02, 0.05); then flouw.Forward(150, 150);
  • Settle after a turn: flouw.Track(120, 0.02, 0.04, 500);
  • Slow down before a corner: flouw.Track(200, 60, 0.02, 0.05, 300);

Approach corners slowly (speed 30 to 80), because the robot coasts after it sees one. And write a comment like // corner 3: turn right above each block. Fixing the course later gets much easier.

Oracle line tracing robot, low side view showing the wheels, LiPo battery and Motion 2350 Pro board

Step 9: Tune it

  • Drifts off on curves: raise kp a little, or lower the speed.
  • Wobbles on straights: raise kd, or lower kp.
  • Twitches or shakes: lower kd.
  • Steady but slow: raise the speed in steps of 20, then re-check kp and kd.
  • Passes the corner before turning: lower the approach speed, or slow down earlier with a ramp.

Change one number, test, write it down. Make it work first, then make it fast. A slow robot that finishes beats a fast one that gets lost.

If it doesn't work

  • No port in Arduino IDE: try another USB-C cable first (some only charge). Still nothing? Hold BOOT, press and release RESET, release BOOT, then drag the UF2 reset file onto the RP2350 drive that appears.
  • Robot steers away from the line: run the motor check in step 4.
  • Follows badly for no clear reason: calibrate again on this track.
  • Timed parts changed: check the battery. A full battery goes further in the same time.
  • Program stops at a junction: TrackLeft, TrackRight and TrackCross stop after 3 seconds. Put a Track before long sections.

FAQ

Do I need to build the Oracle Advanced?

No. It comes pre-assembled and pre-wired. You start with setup, calibration and code.

Do my students need to know line tracing math?

No. The Flouw program does the math. Students learn the Flouw commands and put them together into a course.

Basic or Advanced: which Oracle should my team start with?

The Basic (4 sensors) suits a first line tracing season. The Advanced (16 channels) sees corners, crosses and T-junctions more clearly and runs faster. The Oracle Line Tracing Package has both setups on one robot. Not sure? Message us.

Where do I get the code?

The manual and code come with every Oracle kit, along with Flouw Robotics Lab access.

Ready to run your first course?

The Oracle Advanced comes ready to program, with the manual, the code and free lifetime support. Get the Oracle Advanced Line Tracing Kit. Training a school team? See our school trainings.

More from the blog

See all

Get new posts by email

Tutorials, build stories and tips from Flouw, straight to your inbox.

New posts go to the Gmail you sign in with. You can unsubscribe any time, from any email or from My account.