I am building a full size printed R2-D2 and I am having trouble getting the dome motor to work properly. I am using a USB shield for the XBOX controller and a Cytron SHIELD-MD10 for the motor controller. I can get the motor to turn when I move the analog stick but no matter which way I push it the motor spins in the same direction.
Here is the code
const byte DOMESPEED = 200;
// Configure the motor driver.
CytronMD motor(PWM_DIR, 3, 6); // PWM = Pin 3, DIR = Pin 4.
int domeThrottle = 0;
AnalogHatEnum domeAxis;
domeAxis = RightHatX;
// DOME DRIVE!
domeThrottle = (map(Xbox.getAnalogHat(domeAxis, 0), -32768, 32767, DOMESPEED, -DOMESPEED));
if (domeThrottle > -DOMEDEADZONERANGE && domeThrottle < DOMEDEADZONERANGE) {
//stick in dead zone - don't spin dome
domeThrottle = 0;
}
motor.setSpeed(domeThrottle);
} // END loop()
Anyone can help me? I'm not a programmer. I just play around with things like this.