TROUBLESHOOTING

This page covers errors that may come up after you've already been coding and uploading successfully to your board. If you've never successfully uploaded to your board, visit the First Upload troubleshooting page.

 

Errors and Troubleshooting your Projects

Programming is an experimental process and you should expect to break your code many times. When that happens, the best thing to do is start with whatever information you have and change one thing at a time until you have found the broken bit and fixed it. We break troubleshooting into two parts: hardware (the physical things) and software (the code).

These tips are presented as a numbered list (1,2,3…) but they aren't ordered steps. If you see the error, try option one, then see if your error is fixed. If not, try option two and then see if your error is fixed. Continue down the list.

 

determine if your problem is with hardware or software:

1) Press 'Upload' in your code editor. If you see red highlights on some of your lines of code, or you scroll just below the code editor and see some error messages there, you have a problem with your code! Continue to Software Troubleshooting. 

Go to Software Troubleshooting

2) Replace a piece of hardware with an identical piece. If you expect an LED to turn on and it isn't, replace that LED with another LED. Does your project work now? If so, you had a hardware issue.

Go to Hardware Troubleshooting

Software troubleshooting

The code editor will show you an error message when it has trouble compiling your code and putting it on to Maker Board. These errors aren't always easy to decode, but we've assembled the most common errors and their most common solutions.

All of these recommendations assume that you have completed at least one successful upload of any program to the Maker Board. If you haven't ever been able to upload to Maker Board, you should check the download and installation instructions for the software on the Start pages. There may be a problem with the way the software is installed.

does not name a type
Class 'X' has no member named 'Y'
Expected 'X' before 'Y'
Expected Unqualified ID before 'X'
'X' was not declared in this scope
Conflicting Declaration
Expected Declaration before ' } ' token
Does not name a type

This error is most common when you are creating something in code: usually a variable.

Look at each place where you declare a variable type (like bool, int, float, const). Are each of those words spelled correctly? Are they all lower case letters?

Class 'X' has no member named 'Y'

This error is most common when you are using a library that gives you access to new methods. When you include the library Servo.h , for example, you now have access to the .attach() method. If you try to use .attach() without including the library, you'll see this error.

1) Look for misspellings in your program, especially around the methods. Check capitalization of the method names (these are names that should follow a period (.)).

2) Make sure that the library you're including does actually contain the method you want to use. How? Comment out the first line in your program that uses the method by putting two // marks in front of it. Now click 'Verify' again. If you get another error in the program the next time you used that method, you may be trying to use a method that doesn't exist in the library.

Expected 'X' before 'Y'

This is usually a syntax error: you may have forgotten to type something in that the program requires to run.

1) Check the void setup () section of the code. Does it have curly brace ( { ) after the parentheses? Does it end with a curly brace ( } ) before void loop?

2) Check the void loop section. Does it have a curly brace ( { ) after the parentheses? Does it end with a curly brace ( } ) at the end of the code?

3) Most lines of code end with a semicolon ( ; ) . Is the line that the error highlights missing a semicolon? Is the line above the highlighted line missing a semicolon?

4) Look for other elements of the code that need a 'matching pair'. Every time you use an open parenthesis ( ( ), you will need a closing parenthesis ( ) ). The same goes for curly braces ( { } ).

Expected Unqualified ID before 'X'

This most commonly happens when you try to name a variable starting with a number. Variable names must start with letters.

'X' was not declared in this scope

This most likely means you tried to use a variable someplace where it hasn't been declared.

1) If the error has highlighted a line of your code, look at that line. Are you creating a variable on that line? If so, did you give it a type before giving it a name? Is the text for the type a different color? All valid variable types should turn blue when you type in those letters.

2) Are you using a variable in void loop() that you created inside void setup()? This is related to 'scoping': not all variables you create in the program are available to use in all other areas of a program.

Notes on scope: If you want to use a variable everywhere within your program, declare it at the top of the program, above void setup().

Sometimes, you want a variable to only exist in a limited scope. For example, if you create a for loop : for(int i=0; i<100; i++), the variable “ i ” only exists within that 'for' loop. You can create another for loop: for(int i=100; i>0; i--) and the variable “ i ” is brand new in that 'for' loop.

Conflicting Declaration

This one comes up almost exclusively when you declare a variable multiple times with different types, like declaring an 'int myVariable' and then 'float myVariable'

1) Change one of the variables' names. Make sure if you've already written code with two variables sharing the name to carefully separate them.

Expected Declaration before ' } ' token

This error is simple to understand and hard to fix. When you see this error, the Arduino software will almost always highlight the last closing brace ( } ) in the code. What the error really means, though, is that there are more closing braces ( } ) than opening braces.

The best way to find this error is start at the top of the loop and find each opening curly brace ( { ) in each “for” loop, “if” statement, and everywhere else in your code. Are you closing that command with a curly brace ( } ) when it is complete?

Review the syntax of each statement that you use in your code if you aren't sure how to use braces with your specific statement.

Hardware Troubleshooting

Hardware is the connection between the digital and physical worlds. It also requires a few new skills to ensure everything works properly. There are many types of hardware, so here we cover the most common issues that we run in to. Start at the top and try each solution. Doesn't solve the problem? Move to the next one.

If you’re using unchanged code from example projects and the example isn’t working like you expect it to, replace a component with one of the same type. For example, replace a red LED with a blue LED. If the unchanged code suddenly starts to work, it's a component problem.

1) Does the hardware hookup match the code? That is, if your code says digitalWrite(5,HIGH); , is your LED leg in pin 5? The ports are small and close together, so mix-ups happen all the time.

2) Be sure that the component is well ‘seated’ in the port when you plug it in. When a component is correctly placed into the port, you can turn the project upside down and nothing will fall out. If your components want to slip out of the ports, try inserting the ground pin diagonal to the signal pin. All of the ground row pins do the same thing, so they are interchangeable. This technique helps keep your components firmly inserted.

3) Ensure that none of the wire legs (leads) are touching each other on the same component. Also be sure the legs aren’t touch another component’s legs. Power may pass through the other legs instead of the component itself.

4) Some components can be oriented with either leg in a ground port and the other in a pin port. Some components cannot! Be sure to review your component cards and look for markings on the component itself: components with legs of different lengths, for example, usually need to be oriented a certain way.

5) Watch out for the 5V ports on your Carrier Board. They are needed for some components, but plugging an LED into it and powering your project can ruin the LED by sending too much current through the LED. If you've accidentally plugged a component in to 5V and powered on the project, run a simple test program that uses that component to ensure that it still works.

6) It is possible for some components to stop working over time. LEDs can burn out and button legs can break. If you are having mysterious problems that you still cannot solve, try replacing your component with an identical one. If the replaced component starts working again, it may be time to buy a new component.

go to top