void SimpleMPU6050::initializeInstance() { /* Part of "void setup()" in a general Arduino sketch */ uint8_t c; Wire.begin(); // Initialize the 'Wire' class for the I2C-bus. MPU6050_write_reg (MPU6050_PWR_MGMT_1, 0); // Clear the 'sleep' bit to start the sensor. }
uint8_t AccelGyro::init() { Wire.setModule(0); Wire.begin(); uint8_t c; uint8_t error; Serial1.println("Reading who I am bit"); error = MPU6050_read(MPU6050_WHO_AM_I, &c, 1); Serial1.print("Success. I am : "); Serial1.println(c, HEX); // Clear the 'sleep' bit to start the sensor. MPU6050_write_reg (MPU6050_PWR_MGMT_1, 0); Serial1.println("Sensor started!"); return error; }
void setup() { Serial.begin(9600); esc.attach(ESC_PIN); esc2.attach(ESC_PIN2); esc3.attach(ESC_PIN3); esc4.attach(ESC_PIN4); int error; uint8_t c; Wire.begin(); error = MPU6050_read(MPU6050_WHO_AM_I, &c, 1); error = MPU6050_read(MPU6050_PWR_MGMT_1, &c, 1); MPU6050_write_reg(MPU6050_PWR_MGMT_1, 0); }
void AccelReading::Initialize(){ int error; uint8_t c; //pinMode(led1, OUTPUT); //pinMode(led2, OUTPUT); Serial.begin(9600); Serial.println(F("InvenSense MPU-6050")); Serial.println(F("June 2012")); // Initialize the 'Wire' class for the I2C-bus. Wire.begin(); // default at power-up: // Gyro at 250 degrees second // Acceleration at 2g // Clock source at internal 8MHz // The device is in sleep mode. // error = MPU6050_read (MPU6050_WHO_AM_I, &c, 1); Serial.print(F("WHO_AM_I : ")); Serial.print(c,HEX); Serial.print(F(", error = ")); Serial.println(error,DEC); // According to the datasheet, the 'sleep' bit // should read a '1'. // That bit has to be cleared, since the sensor // is in sleep mode at power-up. error = MPU6050_read (MPU6050_PWR_MGMT_1, &c, 1); Serial.print(F("PWR_MGMT_1 : ")); Serial.print(c,HEX); Serial.print(F(", error = ")); Serial.println(error,DEC); // initialize all the readings to 0: for (int thisReading = 0; thisReading < numReadings; thisReading++) { accelx[thisReading] = 0; accely[thisReading] = 0; accelz[thisReading] = 0; } // Clear the 'sleep' bit to start the sensor. MPU6050_write_reg (MPU6050_PWR_MGMT_1, 0); }