Zumo Bot Uno vice 101

Arduino 1.6.9 for programming. All libraries updated.

When I upload my sketch to my Uno, my Zumo Bot responds as it should.
When I take the exact same sketch and upload to the 101, it’s successful but nothing works.

Any ideas?


#include <ZumoMotors.h>

#define PIEZO_PIN 3 // piezo pin
#define THROTTLE_PIN 4 // throttle channel from RC receiver
#define STEERING_PIN 5 // steering channel from RC receiver
#define BUTTON_PIN 12 // user BUTTON pin // used for toggling the receiver alarm
#define LED_PIN 13 // user LED pin

#define MAX_SPEED 400 // max motor speed - this is the highest value allowable by the motors. do not use values over 400
#define PULSE_WIDTH_DEADBAND 25 // pulse width difference from 1500 us (microseconds) to ignore (to compensate for control centering offset)
#define PULSE_WIDTH_RANGE 350 // pulse width difference from 1500 us to be treated as full scale input (for example, a value of 350 means
// any pulse width <= 1150 us or >= 1850 us is considered full scale)

ZumoMotors motors;

bool alarm = true; //variable to toggle alarm silence when RC signal is not good

void setup()
{
pinMode(LED_PIN, OUTPUT);

// setup button for audible alarm toggle
pinMode(BUTTON_PIN, INPUT);
digitalWrite(BUTTON_PIN, HIGH);

// uncomment one or both of the following lines if your motors’ directions need to be flipped - Pololu
// this original code makes EVERYTHING backwards; corrected by swapping ZumoMotors values - KK
// motors.flipLeftMotor(true);
// motors.flipRightMotor(true);

}

// play alarm on piezo enabled Zumo shield
class PlayAlarm {
int piezoPin;
public:
PlayAlarm(int piezoPin) {
tone(piezoPin, 2000, 100); // high tone
delay (100);
tone(piezoPin, 500, 100); // low tone
};
};

void loop()
{
int throttle = pulseIn(THROTTLE_PIN, HIGH);
int steering = pulseIn(STEERING_PIN, HIGH);
if (digitalRead(BUTTON_PIN) == LOW) alarm = !alarm; // detect button press and toggle value

int left_speed, right_speed;

if (throttle > 0 && steering > 0)
{
// both RC signals are good; turn on LED
digitalWrite(LED_PIN, HIGH);
alarm = true; // reset the alarm if muted; active robot loss of signal allows for alerting

// RC signals encode information in pulse width centered on 1500 us (microseconds); subtract 1500 to get a value centered on 0
throttle -= 1500;
steering -= 1500;

// apply deadband
if (abs(throttle) <= PULSE_WIDTH_DEADBAND)
throttle = 0;
if (abs(steering) <= PULSE_WIDTH_DEADBAND)
steering = 0;

// mix throttle and steering inputs to obtain left & right motor speeds
left_speed = ((long)throttle * MAX_SPEED / PULSE_WIDTH_RANGE) - ((long)steering * MAX_SPEED / PULSE_WIDTH_RANGE);
right_speed = ((long)throttle * MAX_SPEED / PULSE_WIDTH_RANGE) + ((long)steering * MAX_SPEED / PULSE_WIDTH_RANGE);

// cap speeds to max
left_speed = min(max(left_speed, -MAX_SPEED), MAX_SPEED);
right_speed = min(max(right_speed, -MAX_SPEED), MAX_SPEED);
}
else
{
// at least one RC signal is not good; turn off LED, stop motors, and issue audible alert
digitalWrite(LED_PIN, LOW);
left_speed = 0;
right_speed = 0;
if (alarm) PlayAlarm(PIEZO_PIN);

}

ZumoMotors::setSpeeds(right_speed,left_speed); // reversed these from original code for “true steering”
}

Turns out the issue is that the Arduino/Genuino 101 non-100% compatibility. The UNO has 6 pins of PWM support, whereas the Genuino only has 4. These pins do not align how they need to in order to support the Zumo Bot shield. So it's literally hardware incompatibility, not a code issue as best I can tell.

Unfortunately k3nk is right, pin 10 in used as PWM by the Zumo shield but is not PWM capable on the 101. If you feel hacky, you can set pin 10 as input, jumper-wire it to a PWM capable pin (3, 5 or 6) and modify the definition in the library header to match your new setup (https://github.com/pololu/zumo-shield/blob/master/ZumoMotors/ZumoMotors.cpp#L3)