Troubleshooting Tips

I can say from personal experience that troubleshooting the Arduino microcontroller can be one of the most finicky things I’ve ever dealt with as its very difficult to understand at times. Having sketches that mysteriously work or become inoperable, LEDs that turn on when you get too near them, and units suddenly dying for no reason are all issues I’ve encountered as I grew better at handling. To help out others who may have gone through these issues as well as inform the newer guys, here are some tips I have for dealing with pesky errors.

 

1.Is It On?

Though pretty embarrassing to admit, when first starting to program this is going to be the root of most issues. Did you plug everything in yet? Its good to leave everything unpowered until you’re ready for it to start working for safety’s sake, but you have to remember to turn everything on after the fact as well. Along with power, its important to properly identify what units you’re going to use require a voltage 5v or 3.3v supply as some products won’t have a voltage regulator and will be damaged if you incorrectly power it. Be sure to look at the product specification page to ensure everything is connected as it should so you won’t get the magic white smoke that comes when you fry a component.

Also ensure the microcontroller itself has enough power to turn on by providing at least 3.3 volts of electricity. Depending on what you buy there may be special voltages you must supply, so check its documentation to know for certain. If you don’t have the voltage as its either too low or high, use a buck/boost convertor, which will decrease/increase the voltage respectively. I suggest you use a multimeter to verify the correct voltage is supplied.

 

2. Proper Pin Connections

This is the most common issue people face when troubleshooting as the wiring seen in sketches and the wiring that’s actually done is vastly different and not as pretty. Prototype designs made on the breadboard are especially bad as its easy to improperly pin hardware, which could easily result in puffs of smoke and Kentucky- fried Arduinos. Its best to remove all wiring and move step-by-step to wire each unit individually and not jump around from one unit hookup to another. This significantly reduces the chances of consistent errors and ripped out hair. Also ensure you identify if you’re supposed to hook you pins into analog or digital pins, as that’s a common mistake to make as well. If you have issues remembering, draw out a reference table so you don’t need to focus as much on not losing your mind with many components strewn around your project table.

 

3. Sketch Settings

An often overlooked issue, IDE settings are important to inspect before uploading your content to the Arduino. In the Tools section of the IDE, verify you’re using the correct board, processor, COM Port, and programmer. 99% of the issue is selecting the wrong COM Port and board as most people have boards they use for prototyping and boards for actual projects. If you’re unsure of the board you have, navigate to Tools> Get board info, which should remove most of the guess work.

 

Colons, Semicolons  Everywhere!

The bane of my existence is missing a semicolon in a long line of code! Depending on what the line missing the semicolon had, the IDE could throw a cryptic error that leads to hours of frustration. Checking the hardware, pin configuration, IDE settings, power settings and semicolon can take a while once your emotions play into the situation, all because of that ONE semicolon you missed(!). What I normally do is after every line ensure I placed the semicolon at the end. It sounds and is very simple, but something a lot of people overlook.

 

Magic Sketch

All previous entries at least had some explanation as to why it wasn’t working, but here that isn’t the case. Magic Sketch is a magical phenomena where you verify everything is correctly connected and coded, semicolons and all just for the sketch to fail uploading repeatedly. I’ve found several remedies for this:

  1. Save the sketch, close and reopen the IDE.
  2. Go to the sketch location and verify there isn’t a duplicate sketch made by the computer. If you take too long between your last save and change the code at all, the program will save the sketch with a different name attribute. If there is a duplicate sketch, delete it and reupload.
  3. Upload a blank sketch, then overwrite it with the desired sketch.
  4. Copy the entire set of code, open another IDE, then paste and overwrite the file. This has worked, much to my frustration…
  5. Try uploading the code in another Arduino to isolate the issue as either being with the board or something else entirely.
  6. As of this posting, the processor option in the Tools menu has added AtMega328P & ATMega328P (Old One), causing upload issues in the sketch.