0

I have this block of code that declares an enum data type called "motorGroup"

I want to pass a value from this data type into a function that uses a switch case.

When I try this, I get the following error:

error: expected ')' before 'group'

How do I make it so that I can pass the enum into the actuatorPull function and have it be interpreted by the switch-case?

enum{TOP, BOTTOM}motorGroup; long pulses; int ppi = 0; int dist = 0; int speed; void pulseCount() { pulses++; dist = pulses / ppi; } void systemInit() { pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); attachInterrupt(digitalPinToInterrupt(2), pulseCount, RISING); } void actuatorPush(motorGroup group, int speed) { switch(group) { case TOP: analogWrite(4, speed); analogWrite(5, 0); analogWrite(6, speed); analogWrite(7, 0); break; case BOTTOM: analogWrite(8, speed); analogWrite(9, 0); analogWrite(10, speed); analogWrite(11, 0); break; } } void actuatorPull(motorGroup group, int speed) { switch(group) { case TOP: analogWrite(4, 0); analogWrite(5, speed); analogWrite(6, 0); analogWrite(7, speed); break; case BOTTOM: analogWrite(8, 0); analogWrite(9, speed); analogWrite(10, 0); analogWrite(11, speed); break; } } 
0

1 Answer 1

1

To provide enum's typename, the name should come right after enum keyword.

enum motorGroup { TOP, BOTTOM }; 

Otherwise, you are declaring variable name, not typename.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.