0

Enum as function parameter

I'm using Tinkedcad and directly using the raw code editor (without the blocks).

I stumbled upon an error where I want to pass an enum parameter to a function, but the compilation of the function fails. It runs fine on Arduino IDE though. Here's below a sample of the failing code :

"

enum MotorDirection {
CW,
CCW
};

void SetMotorDirection(MotorDirection dir) {
 switch(dir) {
 case CW:
   // Something
   break;
 case CCW:
   // Something else
   break;
}
}

"

If the function takes an "int" instead everything works fine. Can you fix this compilation issue?

Feel free to come back to me if you have any questions.

Best regards.

0 comments

Please sign in to leave a comment.