Arduino Tutorial: How to troubleshoot Arduino projects

Take a deep breath and try to relax. Remember that most makers, both amateur and professional, spend most of their time fixing problems that they themselves have introduced. As we get more experienced we get smarter about finding and fixing problems, but we also develop more complicated and hard to find problems.

What follows is based on my experience debugging hundreds or perhaps thousands of projects, both my own and of others.

General ideas

  1. Pretend you are explaining the problem to someone, either verbally, in email, or in your head. Sometimes while putting your thoughts in order to explain, you spot the problem.
  2. Have someone else look at your problem. Sometimes we become so convinced we did things correctly that our eyes become blind to simple mistakes.
  3. Almost all hardware problems are due to loose or missing connections. Of the remaining, most are due to short circuits i.e. connections you shouldn’t have.
  4. Go back to the very beginning and check basic functionality:
    1. Upload the Blink sketch to Arduino. Verify the LED is blinking. Change the delay, upload, verify that the blinking rate has changed.
    2. If your project involves Processing, verify proper communication with Processing. Use Arduino->Examples->Communication->Graph.
      1. First load the Arduino sketch and verify with the serial monitor that your Arduino is sending numbers and that they change. You don’t need a sensor attached, you can just touch the analog input to generate a different analog reading. Of course if you do have a sensor manipulate that sensor and see that the numbers change.
      2. After you have verified that Arduino is sending numbers, close the serial monitor and test the Graph Processing sketch.
  5. Break complex projects into smaller pieces
    1. If you added lots of sensors or actuators, remove all but one. Upload a simple sketch to test just that. Use the built-in examples to avoid making mistakes: Blink for actuators, AnalogReadSerial or DigitalReadSerial for sensors . If you have a spare Arduino and breadboard, use that to avoid taking apart a large circuit (although later you might need to do just that).
    2. Isolate the problem. If you are having trouble with a specific piece of hardware or part of your program, create a new sketch that will duplicate just that problem.
      1. Make a copy of your original sketch and then remove all of the parts that have nothing to do with the problem you are trying to solve.
      2. If your circuit is complex, build a new circuit with just the parts that are causing you trouble. (This is one reason it’s useful to have more than one of each part.)

      Whether a hardware or software problem, this approach has two immediate benefits:

      1. Sometimes you find an unexpected connection between two parts of the sketch or circuit you thought were completely independent
      2. When the sketch or circuit is simplified to the absolute minimum required to duplicate the problem, it is often easier to spot the problem.

      A third benefit is that if you take your problem to and expert or a forum, they will usually ask you to do just this so that they don’t need to understand your whole project, just the part(s) that is/are causing you trouble.

Specific to sensors

  1. Analog sensors i.e. sensors that put out an analog voltage:
    1. Measure the voltage as close as possible to the sensor with a multimeter. I find it useful to use an alligator clip to attach a piece of wire (22 AWG, solid core) to both multimeter probes. This makes it easier to connect the probes to the breadboard.
      1. Connect the black probe to your circuit ground
      2. Connect the red probe as close as possible to the output of the sensor

      Manipulate the sensor and verify that the voltage changes. If the multimeter shows properly changing voltages, then move the red probe as close as possible to the analog input on the Arduino, ideally the solder pad on the back of the Arduino. If the voltage disappears, there is a missing connection somewhere in between.

    2. If the voltage does not change, verify that the sensor is getting electricity:
      1. Connect the black probe as close as possible to the ground input to the sensor
      2. Connect the red probe as close as possible to the 5V input to the sensor
      3. Verify reading 5V
    3. If you don’t read 5V, then your sensor is not getting 5V.  Move the red probe and then the black probe closer to the Arduino until you find the missing or bad connection.

See also

  • debugging near the end of

Much more to come. I appreciate feedback, especially:

  1. Other suggestions
  2. Tricky problems that you can’t figure out how to solve
Print Friendly
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Leave a Reply

Your email address will not be published. Required fields are marked *