Using MPU6050 SparkFun breakout to keep HS-45HB servo level

Hello,
My name is Roman. I've just joined the ARDUINO FORUM and am seeking guidance on a senior project I have in NYIT as a mechanical engineering student. I am rather new to electrical engineering although I do have general knowledge and experience in it, as for programming it seems that Im in over my head for the short amount of time I have left before the semester ends. If anyone has any pointers and guidance on anything in regards to the project, please let me know.
I have seen this done on youtube and on professional GP motorcycles. I want to "reproduce" a camera mount that will tilt as a motorcycle is leaning into the turn, making the camera constantly parallel with the horizon on a 1 DOF axis (pendulum-like, side-to-side motion).
I have been talking back and forth with SparkFun.com and have received advice on the hardware I would need.

Here is a list of the things I have purchased based on the suggestions:
-MPU6050, http://www.sparkfun.com/products/11028
-Arduino UNO, http://www.sparkfun.com/products/11021
-Arduino MINI Pro (5V), http://www.sparkfun.com/products/11113
-FTDI Basic Breakout (5V), http://www.sparkfun.com/products/9716
-Hitec HS-45HB Servo, HITEC RCD USA

As you can see I was intending to make the mount rather small. At first I have been fiddling with the UNO, Servo, and MPU only. I was not able to connect to the MPU. I am almost certain that I had the wiring setup correctly and was able to test the servo with an ADXL345 today with great success but twitchy. I have received great help from Jeff Roweberg in regards to the MPU6050 code that he provides online and, after calling SparkFun, found out that unfortunately the MPU6050 I have received seems to be faulty so I am sending it back to receive another one.

Since I cannot test until I get the new MPU, I wanted to know if anyone can point me towards sources of adding a servo to the MPU code so I can do my HW while the MPU is on its way.

I also played around with the servo and the SWEEP example provided with the arduino software. I have encountered a problem with the range of motion for the servo; when returning to 0 degrees, it will try and go past its rotational limit. I got the same thing with the ADXL345 connected to it (CODE: http://maxim.wf/arduino_code/ADXL345_Accelerometer.pde ). Can I solve this when programming it into the MPU code? What is it called when the servo tries to do that?

Heres an example I found online and modified to the range of motion I would like/need from the servo with 1590 being center from experimenting with it, I don't know how it works but that is when the servo is centered:

// Sweep
// by BARRAGAN <http://barraganstudio.com> 
// This example code is in the public domain.


#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
 
int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  myservo.attach(2);  // attaches the servo on pin 2 to the servo object 
} 
 
 
void loop() 
{ 
  for(pos = 1590; pos < 2360; pos += 10)  // goes from 90 degrees to about 170 degrees 
  {                                  // in steps of 10 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 2360; pos >= 1590; pos-= 10)     // goes from about 170 degrees to 90 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
   {
    myservo.write(pos);              // stops the servo at 90 degrees for 1.5 sec
    delay(1500);
  }
  for(pos = 1590; pos >= 780; pos -= 10)  // goes from 90 degrees to 0 degrees 
  {                                  // in steps of 10 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 780; pos < 1590; pos += 10)  // goes from 0 degrees to 90 degrees 
  {                                  // in steps of 10 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
   {
    myservo.write(pos);              // stops the servo at 90 degrees for 1.5 sec
    delay(1500);
  }
}

If anyone has any advice it will be greatly appreciated.Thank you!

Roman

if anyone can point me towards sources of adding a servo to the MPU code so I can do my HW while the MPU is on its way.

I think you are trying to attach the servo to the wrong thing. There is no code on the MPU, and I can't see how you can attach a servo to code anyway.

I have encountered a problem with the range of motion for the servo; when returning to 0 degrees, it will try and go past its rotational limit.

Then, it's lower limit is NOT 0 degrees. Don't try to go beyond it's lower limit.

I got the same thing with the ADXL345 connected to it

How does adding MORE hardware to the mix solve anything? You've got one piece not operating as expected. The solution is NOT to throw more hardware into the mix. It is to understand what is going on with the code and hardware you currently have!

Can I solve this when programming it into the MPU code?

Not until you begin to understand what you are programming. Hint: It isn't the MPU or the servo or the camera.

What is it called when the servo tries to do that?

Unrealistic expectations on your part.

I don't know how it works

Why not? There are only three statements in that whole mess of code. A for loop, a servo.write() statement, and a delay() call.

First thing you should do is figure out which of those curly braces are needed, which are optional, and which are just plain silly. Get rid of the sill ones.

as for programming it seems that Im in over my head for the short amount of time I have left before the semester ends.

Good thing you didn't wait until the last minute, then.