Arduino boards, and the many affordable microcontrollers that came in their wake, changed hobby electronics forever. What was once the domain of the super geek, armed with extensive knowledge of electronics and computing, is now available to all.
The price of the hardware is always dropping, and the online community is always growing. We’ve previously covered getting started with an Arduino, and there are lots of great beginner projects to get you acquainted, so there’s no reason not to jump right in!
But today, we will cover a few mistakes frequently made by folks who are new to this world, and how to avoid them.
Most Arduino boards have a power regulator on board, meaning you can power it from USB or a power supply. While each board differs in exactly what it can take, it is typically 7-12v input through a DC barrel jack or through the VIN pin. This brings us nicely on to our first mistake:
1. Externally Powering the Board “Backwards”
This first one catches people out all the time. If you are powering your board from a battery or power supply you must make sure that V+ goes to the VIN pin, and the Ground wire goes to the GND pin. If you get this backwards, you are pretty much guaranteed to fry your board.
This seemingly obvious error happens more frequently than you would think, so always check your power setup before switching anything on!
When the air smells of fried Arduino, more often than not this is the main reason. The second most likely is because something tried to draw too much current from the board. Knowing how much power your components need compared to how much your board can provide is essential.
A common error when starting out is managing to cause short circuits. These occur when parts of the circuit are joined in places they shouldn’t be, giving the power a simpler route to follow. This will at best result in your circuit not acting like it should, and at worst with fried components or even a fire risk!
To avoid this when using a breadboard, it is important to understand how a breadboard functions.
The important aspect here is remembering how the rails work on each board. On full and half size breadboards, the outer rails work horizontally and the inner rails vertically, with a gap in the middle of the board. Mini breadboards only have vertical rails.
The easiest way to avoid causing a short on a breadboard is simply to check your work before powering up your device. That last-minute glance can save you a multitude of woes!
3. Soldering Mishaps
The same problem can happen when soldering Arduinos or components to protoboard, especially with smaller boards like the Arduino Nano. All it takes is a tiny blob of solder between two pins to cause a short which could wreck your microcontroller. The only way to avoid this is to be vigilant, and practise soldering as much as possible.
4.Wiring Things Up to the Wrong Pins
Working with microcontrollers means working with pins. Most components and many boards come with pins to attach them to protoboard. Knowing which pin does what is essential to making sure things work the way you want them to.
A common example is the MOSFET. The three legs on a MOSFET are called the Gate, Drain, and Source. Mixing any of these up could cause power to flow in the wrong direction or cause a short circuit. This can destroy your MOSFET, Arduino, appliance, or if you are really unlucky, all three!
Always look for a datasheet or pinout of a component before using it to determine exactly which pin goes where, and how much power it requires to use.
5.Syntax Errors in Code
Moving away from the hardware side of Arduino, there are plenty of mistakes to be made when coding. The most typical errors include:
Missing semicolons at the end of lines
Missing/wrong type of brackets
Any one of the above problems, while minor, will stop your program working as it should. Take the Blink sketch for example. Below is the simple Blink.ino sketch included with the Arduino IDE, with the help text removed. At first glance it looks more or less OK, doesn’t it?
This code will not compile, and there are 5 reasons why. Let’s go over them:
Line 2:Missing semicolon.
Line 4:Missing function brackets.
Line 6:Wrong type of brackets.
Line 7: DigitalWrite function spelled incorrectly.
Line 8/9:Missing closing curly brace.
Here’s what that code should look like:
Each one of these errors, though minor, will stop your program from working. It can be quite frustrating at first to tell exactly what is wrong, though it does get much easier with time. A good tip to getting used to Arduino programming is to have another program open which you can refer to, as in most cases the syntax and formatting is the same between different programs.
If coding an Arduino is your first foray into coding, welcome! It’s a rewarding hobby to learn, and given how certain types of programmers are in demand, it could be a great change of career! There are good habits to learn as a coder, and these habits apply to all programming languages so it’s worth learning them early.
The extensive and ever growing list of libraries available for Arduino is one of the things that makes it so accessible for newcomers. Libraries written by experienced coders and released for free make it possible to use complex components such as individually addressable LED strips and weather sensors without needing to know complex coding.
You can install libraries straight from the IDE by selecting Sketch > Include Library > Manage Libraries to bring up the library browser.
Once you have installed your libraries then you can use them in any project, and many come with example projects of their own. There are two possible pitfalls here.
Using code that requires a library you do not have.
Trying to use parts of a library that you have not included in your project.
In the first instance, if you find a piece of code that seems perfect for your project, only to find it refuses to compile once you have it in your IDE, check that it doesn’t include a library that you have yet to install. You can check this by looking at the #include <xxxx> at the top of the code. If it includes something you haven’t installed yet it isn’t going to work!
In the second case you have the opposite problem. If you are using functions from a library you have installed onto you computer and the code refuses to compile, it may be that you forgot to include the library in the sketch you are currently working on.For example, if you wanted to make use of the fantastic ABCD library with your LED strips, you would need to add #include “ABCDLED.h” at the start of your code to let it know to look for the library.
7. Shooting for the Moon
This one isn’t a specific problem, and more a question of patience. Arduinos make it very easy to jump in and get started prototyping ideas. While it is true that difficult projects make for quick learning experiences, it is worth starting small. If the first project you attempt is uber complicated you will likely fall foul of one of the above problems, leaving you frustrated, and potentially with fried electronics.
The great thing about working with microcontrollers is the sheer amount of projects available to learn from. If you plan on making a complex lighting system, starting with a simple traffic light system will give you the basis to move on. Before creating a huge LED strip light show, maybe try something smaller as a test run like the inside of your PC case.
Each little project teaches you another aspect of using Arduino controllers, and before you know it you’ll be using these clever little boards to control your whole life!
The learning curve for Arduino can seem quite daunting to the uninitiated, but its dedicated online community make the learning process much less painful. By watching out for easy mistakes like the ones in this article, you can save yourself a multitude of frustrations.
Now that you know which mistakes to avoid, why not try building your own Arduino, there’s no greater way to learn how they work.
Are you starting out with Arduino boards? Have you fallen into any of these traps? Are there any we have missed that caught you out? Let us know in the comments section below!