I am able to move motors using AfMotor Shield Library. ( https://github.com/adafruit/Adafruit-Motor-Shield-library )
Like :
AF_DCMotor insertionMotor(1);
AF_DCMotor pumpMotor(2);
void setup()
{
insertionMotor.setSpeed(255);
pumpMotor.setSpeed(255);
insertionMotor.run(RELEASE);
pumpMotor.run(RELEASE);
insertionMotor.run(FORWARD);
pumpMotor.run(FORWARD);
}
But if I want to write it like this, only the motor with the template expansion that I called last works.
enum class direction {
FRW = 0x01,
BCKW,
};
template<int n, direction type>
class Motor : public AF_DCMotor {
public:
Motor() : AF_DCMotor(n) {
setSpeed(255);
run(RELEASE);
run(type);
}
};
Motor<1, direction::FRW> fanMotor;
Motor<2, direction::FRW> pumpMotor;
Only the pumpmotor is running. Or if I call the fanMotor after the pumpMotor, it still works.If I remove pumpmotor and leave only fanMotor, the fanMotor also works. Is there something I overlooked?