Introduction: Enhancing LEGO SPIKE Prime Line Follower With C: Speed & Stability Comparison

I tried controlling the LEGO SPIKE Prime using C language to evaluate its usability, processing speed, and potential for robot competitions. To test its performance, I implemented a Line Follower algorithm.

Two Key Experiments

  1. Comparing the Line Follower performance using SPIKE App’s Word Blocks vs. C language
  2. Maximizing Line Follower speed using C language with PD control


Supplies

1 PC with Windows 10 or 11 operating system.

Step 1: Comparing SPIKE App Word Blocks Vs. C Language

I created a Line Follower program using both SPIKE App (Word Blocks) and C language, keeping the control logic the same.

The C language version provided more stable driving performance compared to the SPIKE App.

Below is the source code for both versions:

SPIKE App (Word Blocks)

C language

Step 2: Improving Line Follower Speed With C

I tested how much I could increase the Line Follower speed using C language.

Without extensive tuning, I achieved speeds of approximately 820 deg/s.

Adding a second color sensor or optimizing the robot assembly could further improve stability.

Step 3: Development Environment & Resources

For C programming, I used this development environment.

If you want to try it, there is a beginner-friendly tutorial available, including a trial (as of February 2025).

🔹 Download the program used in this article: [Download Link]

Step 4: Future Tests & Robot Competition Applications

I plan to conduct further tests on the usefulness of C language for robot competitions and will share my findings in upcoming articles. Stay tuned!

Step 5: To See More