Code Examples

Code Examples

Feedback Controller (PID) for straight line following
  • Download the code below into a folder, and check the project path is ok in the RoboJDE IDE. Edit it if necessary.
  • Build and download the code onto a robot that has two slotted sensors as shaft encoders. The sensor ports and motor ports need to correspond to those used in MyBot.java .
  • There is a menu when the code starts. Move through the options with the Stop button. Select an option using the Start button. Within an option press Stop again to end the program, and then Start to re-run the menu selection.
  • The controller will not cope with large systematic sensor errors.
  • Edit the controller gains in the files GoStraight.java etc. This will make the controller more or less stable.