Osepp Motor & Servo Shield V1.0 and Arduino 101. Servo crashes

Two Wheel Self Balance Robot.

Oops. Brought the wrong motor. I've spend $ 20 for Osepp Motor. But I don't want buy another motor shield and leave Osepp abandon. What's the problem?

Well, I've spend a week trying to make two servos work. Failed hundred of test on servo.h.
One servos works fine on CarieIMU. Tilting around. Messing around. Opening Serial monitor screen, few seconds, it crashes when you use two servos & intel arduino 101. I give up. Does anyone have better self balance robot code?

#include "CurieIMU.h"
#include <Servo.h> 
Servo myservo,  myservo2;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600); // initialize Serial communication
  while (!Serial);    // wait for the serial port to open

  // initialize device
  Serial.println("Initializing IMU device...");
  CurieIMU.begin();

  // Set the accelerometer range to 2G
  CurieIMU.setAccelerometerRange(2);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
  myservo2.attach(10);  // attaches the servo on pin 10 to the servo object 

}

void loop() {
  int axRaw, ayRaw, azRaw;         // raw accelerometer values
  float ax, ay, az;

  // read raw accelerometer measurements from device
  CurieIMU.readAccelerometer(axRaw, ayRaw, azRaw);

  // convert the raw accelerometer data to G's
  ax = convertRawAcceleration(axRaw);
  ay = convertRawAcceleration(ayRaw);
  az = convertRawAcceleration(azRaw);

  // display tab-separated accelerometer x/y/z values
  Serial.print("a:\t");
  Serial.print(ax);
  Serial.print("\t");
  Serial.print(ay);
  Serial.print("\t");
  Serial.print(az);
  Serial.println();

  //////////////////////////////////////
  //                                        
  //  Balance Code failed.       
  //            
  //                                       
  /////////////////////////////////////


  // wait 5 seconds
  //delay(5000);
}

float convertRawAcceleration(int aRaw) {
  // since we are using 2G range
  // -2g maps to a raw value of -32768
  // +2g maps to a raw value of 32767
  
  float a = (aRaw * 2.0) / 32768.0;

  return a;
}

If the exact code in your example above is failing, I suspect a power issue.
How are you powering the 101? Do you have an extra power supply to the shield?

That code snippet runs fine on my 101, without servos physically attached.

It won't help with this problem, bu as an aside - I suggest you perform an auto calibration at the start - if your balance robot can be assumed to always startup in the same position. Otherwise you may need to save these values off to non volatile memory for future startups. The 101 does not currently remember previous calibrations, or maybe my desk is at a strange angle :wink: