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?

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

1 PC with Windows 10 or 11 operating system.
SPIKE Prime
- Motors:
- Left Motor: Port C
- Right Motor: Port D
- 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
- Kp is the proportional gain (tuning parameter)
- 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

We used an R-shaped line course:
- The first half is a series of curves, which requires frequent, responsive adjustments.
- 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



Video
In the video, we test three different values for Kp:
- Well-tuned → smooth behavior
- Too low → weak corrections
- Too high → unstable oscillation
【Free Trial】Start C Language Programming With Afrel's Educational Materials

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