Protocol for avoiding pointers

This can be simplified down to

  activeMotorID = motor_id;

or, better


if (motor_id < 5 && motor_id > 0)
  activeMotorID = motor_id;
else
  Serial.printf("Bad motor_id %d\r\n",motor_id);

The switch/case statement has hidden powers, but you don't use them :slight_smile:

They are (assuming we are all using GCC-based compilers)

  1. case ranges: e.g. case 1...10:
  2. ability to fallthrough from one "case" to another
  3. "default" statement
1 Like