Looking for common bugs in Arduino projects

promotion rules (especially "integer promotion" on AVRs when int is 16bits) leading to incorrect math:

unsigned long delayTime = 1000 * 60 * 10;  // 10 minute delay

Misunderstanding pin numbers vs functions:

#define MYINPUT 3
  :
  pinMode(MYINPUT, INPUT_PULLUP);
  while (MYINPUT != LOW) {
    // wait for button push
  }
  LED_BUILTIN = HIGH;   // (less common)

Arduino Pin number vs Chip Pin Number vs port Bit Number (especially on non-AVR and bare-chip builds.)

PROGMEM confusions.

Code using Serial that assumes Serial.available() means ALL of the expected data is available.

Code using the more advanced Serial functions (eg Serial.parseint()) that end up pausing for a long time becase there is no terminating character and the default time out (1s) happens.

3 Likes