Collection of the most common beginner-bugs and how to solve them

At the moment this is just a raw collection.
Not well formatted, not in a certain order just some keywords what I came across in the forumt
therefore in general discussion maybe later moved to introductional tutorials

Stuck in a while-loop: if the conditions defined for the while can not change to false
you are stuck
most common reasons:

  • no updating of the variables used in the while-condition
  • assigning by a single "=" instead of comparing with a double "=="

using delay (instead of non-bocking timing)

not learning the basics

not knowing how step-chains work

to small variable size

not using functions

That's for me - I've no clue what this is :slight_smile:


a couple more common ones

  • using = instead of ==
  • wrong nesting of compound statement ({} not well organised)
  • adding a extra semi colon after an if condition, like
if (condition) ;
  doSomething();
1 Like
  • off-by-one on arrays.
  • strings missing space for terminator, or missing terminator when manipulated
  • not knowing limits of data types
  • not knowing what/how data types get used in calculations (though this can get tricky).
    C

1). Index outside of array bounds - often in for loops by using <=. Example :

for (int x = 0; x <= MAX; x++)
   myArray[x] = 0;

2). Not using arrays at all, and repeating lots of similar code.

3). Declaring variables inside a switch/case block.

4). Not turning on compiler warnings.

5). Not including the required library.

Me neither.

1 Like

Tips and Traps by Nick Gammon
http://www.gammon.com.au/tips

Biting off more than can be chewed.

image

connecting GPS TX to Arduino TX and GPS RX to Arduino RX. who could get anything so intuitive wrong?

Big problem when we had DTE / DCE equipment and Nul modems . . .

Good old days. :older_man:

Hey, I resemble that remark! :rofl:

Not using enough print statements.

1 Like

Hitting the "coding keyboard" before doing enough (or even any) thinking, and not drawing some kind of flowchart of what you want to do.

Not bothering to try any of the examples in the IDE and elsewhere before diving into a project.

2 Likes

image

Let me reiterate

Using int type with millis() as in

int t;
...
t = millis();

Also, falling into the "XY Problem" trap. Not a code bug, but a mind bug...

1 Like

Those were good days :nerd_face:

Yeah I like that, and it goes to my one about Think first, Code second.

Arduino FAQs

1 Like

Using String objects on an Arduino with limited RAM.

Trying to power a servo from an Arduino.

1 Like

Doesn't everybody do this, like all the time?

Beginners almost always do. Experienced programmers have learned to embrace the wise words of Mr. Eastwood.