O'Reilly logo

Make an Arduino-Controlled Robot by Michael Margolis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. Debugging Your Robot

Complex projects inevitably throw up obstacles in the form of bugs. As these arise, you can congratulate yourself for choosing such a challenging project and bear in mind the satisfaction you will feel when all the problems have been overcome. Here is some software that should help you find and fix problems you may encounter.

Identify the Symptoms and Localize the problem

Seeing What the Robot Is Doing

Visualizing data from the sensors in real time can be tremendous help in understanding what is actually happening in your sketch. Figure C-1 shows the screen from a Processing sketch that enables you to easily view Arduino values.

Arduino Data Displayed in Processing

Figure C-1. Arduino Data Displayed in Processing

Figure C-1 depicts the analogRead values from left, center and right and sensors used in line detection. The grey numbers in parentheses on the right indicate the possible range of values, the following number is the numeric value sent from Arduino.

The figure shows the values when the robot is straying slightly to the right of a dark line it is trying to follow (the values increase when the sensor is over the line). The Position value goes positive when straying right and negative when left. The Position value is used in the line following sketch to adjust the robot direction so it stays on the line. The Distance value is in inches and is obtained from the ping distance sensor.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required