Looking for common bugs in Arduino projects

Here is a list that I put together some time ago

Feel free to use some/all of it if it helps

Code testing a condition has a semicolon at the end of the test

Code with an array in it strays outside of the array bounds

Code that does any comparisons uses x = y instead of x == y at some point

Code that uses a for loop tests the wrong final value of the loop variable

Code with a while loop in it never changes the condition so the loop never ends

Code with a while loop in it never executes because the loop condition is immediately true

Code using Serial does not have Serial.begin()

Code with Serial.begin() in it sets the wrong baud rate

Code using Serial.available() with the Line Ending not set to "No Line Ending"

Code using SoftSerial uses 2 or more instances

Code that reads digital input has the input pins floating

Code that uses serial input or output uses pins 0 and/or 1 for something else

Code that divides one number by another uses int for the result even if the result will be a float

Code that divides one number by another uses ints when a float result is expected

Code uses a variable type inappropriate for the data being held

Code that uses global variables has local variables with the same name

Code with missing or extra curly brackets

3 Likes