Testing and Debugging with the Arduino IDE
Testing and debugging are essential parts of every development process. Testing becomes more important and more difficult the more complex a robot is. As we have already seen, even a relatively simple Arduino robot consists of several physical subsystems, such as motors, sensors, batteries, the Arduino board itself, and all the wiring in between. The program that runs on your robot also consists of several components, including hardware interfaces, external libraries, and tasks that need to cooperate with one another to efficiently share CPU resources.
It is common for robot builders, especially less experienced ones, to build an entire robot, write the program for it, and then test the hardware and software all at once. It is very unlikely that everything works as expected on the first attempt, and trying to identify the underlying problems can be very difficult and a major source of frustration in this scenario. This approach is sometimes...