MPU 6050 and servo and arduino

Ok, so I was going to try and control a servo with an MPU 6050 using it's gyroscope capability first and then once I had done that, try out accelerometer capability.

I've tried looking all over the internet for how to set it up and code it but anything I try doesn't work. I solved a problem to do with some libraries so they don't trouble me any more, but I cannot get values from the gyroscope and can't control the servo. There's no evidence it is working by code or hardware apart from a few lights.
So my question is, does anyone know how to set it up, such as pins for the MPU gyroscope and especially the code which needs to be used?

You didn't post the code you're currently testing with, no link to the datasheet of the sensor, no link to the libraries used. Did you read the sticky post at the top of the forum?

Ok, here is a picture of the mpu6050 pins, it is the standard arduino one MPU: Arduino Playground - HomePage

Data sheet: http://invensense.com/mems/gyro/documents/AN-MPU-6000EVB.pdf

The code is:

#include <Servo.h>
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
MPU6050 mpu;
int16_t ax, ay, az;
int16_t gx, gy, gz;
Servo myservo;
int val;
int prevVal;
void setup() 
{
    Wire.begin();
    Serial.begin(38400);
    Serial.println("Initialize MPU");
    mpu.initialize();
    Serial.println(mpu.testConnection() ? "Connected" : "Connection failed");
    myservo.attach(9);
}
void loop() 
{
    mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
    val = map(ay, -17000, 17000, 0, 179);
    if (val != prevVal)
    {
        myservo.write(val);
        prevVal = val;
    }
    delay(50);
}

Remove the servo, and try to make the MPU-6050 work by sending data to the serial monitor.

The Arduino board can not supply enough current at the 5V pin for the servo motor. You need a seperate power supply for the servo motor.

Is the MPU-6050 working at all ? If not, use the i2c_scanner. Also use 5V to the VCC of that board, it has a voltage regulator to make its own 3.3V.
http://playground.arduino.cc/Main/I2cScanner

Ok, I now know that the mpu is in fact working. I tried an I2C scanner to check the connection is right and it is.

However when I try to run the code I posted all that comes up on the serial monitor is some symbols.
It should be printing specific words and values?

I also tried the code here: https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/Examples/MPU6050_raw/MPU6050_raw.ino
and random symbols just scoll across the screen?
I don't understand why it is doing this!

I also need to know how to connect 4 mpu6050's to one arduino mega2560.
I really need to connect 4 to one arduino mega2560 only

thankyou

Look at that sketch, it sets the baudrate at 38400.
You have set the serial monitor in the Arduino IDE also to 38400.

There are more requests to use more than one MPU-6050 with the i2cdevlib. I don't know if Jeff Rowberg is working on that.

You can use two MPU-6050 on the same i2c bus (set one AD0 high by connecting it to 3.3V).
But with four you need a multiplexer for the i2c bus. For example a simple logic mux or a special chip.

Ok thankyou for that.
I adjusted the baud rate and it fixed my problem, I didn't even notice it wasn't set properly!
One other question:
First I should probably better explain what I want to do.

So I need to use 4 mpu's most likely just the gyroscope on it. I want to gather the values onto the Arduino and then wirelessly send them to another arduino through this awesome little shield: http://www.opensourcerf.com/rfd21815-wireless-inventors-shield-for-arduino.html. Schematic/manual for the shield is on the page for your reference.

About the multiplexer I have found a few and am unsure about what to get. Which would you say is ideal from this page: http://search.jaycar.com.au/search?w=multiplexer&view=list
I was thinking the 4 or 8 channel chip

I also found this one: http://australia.rs-online.com/web/p/multiplexer-switch-ics/7879106/

-Do I only need one chip for 4 MPU6050's if I get a 4 or 8 channel chip?

Is there any other way to connect 4 MPU's say if I have 2 arduino's and combine all values on one to be sent off.

Thankyou for your help so far, it has really helped