Thinking of Joining a Robotics Competition With SPIKE Prime?

by AfrelEdTech in Circuits > Robots

26 Views, 0 Favorites, 0 Comments

Thinking of Joining a Robotics Competition With SPIKE Prime?

サムネイル.png

Thinking of joining a robotics competition?

Or maybe you're tired of the zig-zag motion from ON/OFF line-following, and want a smoother ride?

This article introduces Proportional (P) control using the SPIKE Prime robot with C programming. You'll see how changing the gain (Kp) affects the robot’s behavior as it follows a line on an R-shaped course. We also include a demo video at the end, so you can see each version in action.

Supplies

スクリーンショット 2025-06-20 084444.png

1 PC with Windows 10 or 11 operating system.

SPIKE Prime

  1. Motors:
  2. Left Motor: Port C
  3. Right Motor: Port D
  4. Color Sensor: Port A

What Is P Control?

P control (Proportional control) adjusts the robot’s steering based on how far it is from the line. The further off it is, the more the robot corrects its direction.

The formula is simple:

correction = Kp × error

  1. Kp is the proportional gain (tuning parameter)
  2. error is the difference between the sensor reading and the target value (e.g., line center)

By adjusting Kp, you can make the robot steer more gently or more aggressively.

Course

Rcourse.png

We used an R-shaped line course:

  1. The first half is a series of curves, which requires frequent, responsive adjustments.
  2. The second half is a long straight line, good for testing steady-state behavior.

This combination makes it easy to observe how different Kp values influence performance on various track sections.

Program

program-Kp1.png
program-Kp3.png
program-Kp05.png

Video

In the video, we test three different values for Kp:

  1. Well-tuned → smooth behavior
  2. Too low → weak corrections
  3. Too high → unstable oscillation


【Free Trial】Start C Language Programming With Afrel's Educational Materials

Guide to running SPIKE Prime in C language

Are you intrigued by the idea of programming your SPIKE™ Prime with C? Did you know that Afrel is a key information provider for SPIKE™ Prime?

To meet the demand of those who want to "learn more about SPIKE™ Prime " and "try programming in C," Afrel has developed and sells educational materials for learning C language programming with SPIKE™ Prime.

Stepping up from Python to C is an excellent opportunity to further enhance your programming skills. Learning C will give you a deeper understanding of how computers work and enable more advanced control.

Afrel's C language materials are designed for beginners, ensuring a smooth learning experience. Why not take this chance to discover the joy of controlling SPIKE™ Prime with C and expand your programming horizons?


If you're ready to tackle C language programming, click the link below for more details.

Learn more about SPIKE™ Prime C Language Programming Materials here