Hi, I'm Becky Stern,
and today we're troubleshooting your Arduino project.
It can be really tough to learn all the things
that could possibly go wrong while creating an Arduino project,
whether it's your wiring, your code, or your software settings-
But I'm going to help.
Let's get into a detective mindset, get out your multimeter,
and let's figure out what's going on.
We'll cover three main problems you could be having.
You can skip to the chapter that's most relevant to you at the moment.
The first is your code doesn't compile when you click the Verify button.
You've got red errors in the console window below your sketch.
First step: Read the error message.
Always read the error message.
If the error message says “expected ‘;’ before ‘}’ token” or similar,
then you're probably missing a semicolon
or have a misplaced curly brace, parentheses or other syntax error.
The report will identify the area where the problem is,
but may highlight an area next to or related to the problematic spot.
You can double check your sets of parentheses and curly braces
by moving your cursor to one to see its highlighted match.
It's super common to accidentally erase or
misplace syntax elements when composing your program.
If you saved a version of your code
at a previous milestone, you can open that file up and compare the two.
To help sleuth out the issue.
If the error message says “No such file or directory”
you are missing a library required by the program.
Try looking it up in the library manager and then install it.
Or install it manually by downloading it and putting it in your libraries folder,
making sure it's named properly.
Learn more in our previous episode about Arduino libraries.
The second problem you're likely to have is that you get an error
When you click the upload button-
you aren't able to program your Arduino board.
As before, first thing you should do, read that error message.
If it says “can't open device” or “programmer is not responding,”
then you may not have the correct board or port selected in the tools menu.
Oftentimes when you unplug your board and plug it back in,
as you should be doing whenever you make changes to your circuit,
your Arduino IDE can forget which port you had selected.
And if this is your first time using a new board,
you may also need to double check
you have installed the necessary drivers and board support if required.
To do so, read the product documentation where you'll find the board's URL,
which you'll then paste into the Arduino preferences.
Then you can find your board in the board's manager and install it.
If everything's configured properly, you can select the proper board
and port from the menu and upload your code.
If your board appears in the list, it means your board support is installed.
Having the wrong board selected can also cause compilation errors.
Not all boards have the same programable features.
If your board doesn't appear as one of the available ports,
it could mean that you're missing a software driver or it could mean
your USB cable is a charge-only cable.
Be sure you're using a cable that is known to support data,
double check the product documentation to see if you need a driver
and try using a different USB port on your computer.
As usual, with technology, sometimes you just need to restart
your Arduino software or your whole computer and try again.
There are a few less common problems that could be at play here too.
Arduino will act weird if it's installed in the wrong place on your computer.
I've had students try to run the app from their downloads folder on the Mac,
which results in some pretty vague error messages regarding permissions.
Doesn't usually happen on Windows.
Even less common is a dongle problem, but it does happen.
If you're using a USB adapter and having issues, try swapping it out,
especially in favor of a powered USB hub
or a new cable that eliminates the need for an adapter altogether.
The third problem you're likely to have is that your program compiles and uploads,
but it just doesn't do what you want it to do.
Double check that the pin number you specified in code is the same pin
number connected to your device and double check your power and ground, especially.
If you have shorted power and ground.
Your computer will detect the current draw and protect itself by shutting power
off to the USB port.
You'll usually get a warning about a device
using too much power on your computer.
You may not be able to use this USB port again until you restart your computer
to troubleshoot your wiring.
Be sure your circuit is unplugged from power
and set your multimeter to continuity mode.
Touch the probes on either end of the thing that should be connected.
To double check that they are. [Multimeter beeping]
And each thing that shouldn't be connected isn't.
Occasionally one of your breadboard wires might be invisibly broken inside
an area of your solderless breadboard
isn't springy enough to make good contact anymore,
or you just aren't seeing that something is plugged into the wrong spot
and the multimeter is the way to check for these problems.
After rectifying any compilation, upload, or wiring issues,
you may still have a fair bit of code wrangling to get the desired output
from your circuit.
You can add some Serial.print() statements to various parts of your code
to find out if they are executing and how often.
The Arduino site has a reference section that describes
each bit of the whole programing language by groups of commands
with simple samples demonstrating each one.
Don't make the common mistake of under-utilizing this important resource.
I've been doing this a while and I still look up stuff all the time.
They've also got a more thorough list of error messages and what they mean,
and there are also many community resources you should check out too,
like researching your questions and error messages in online
forums and sharing your own projects too.
I've put links to some resources in the description.
Leave your advice about electronics troubleshooting in the comments
so we can all learn together.
Check out this series playlist with the rest of the series and subscribe
so you don't miss the next one.