This is an example I developed a while ago but am adding it as a post on the new site now.
The intent of this example is two-fold
- I want to show how you can change the behavior of a program by programming multiple modes and setting the mode through some external interface, in this case it’s the onboard button.
- I want to show the differences in line following methods, in particular showing how basic line follow, while crude, will achieve satisfactory results. PID with only P provides slightly better results, especially in cases where the path has drastic changes. Lastly, a PID with PD provides even better results by dampening the effects of P.
Some caveats
- This only works with the Sparkfun Redbot which we have a few of here in the lab
- The sensors on the Redbot are so far apart, the PID modes do not work very well. I have modeled and 3D printed some brackets for the IR arrays that place the sensors closer together so just ask for one if you want to try this.