expected '}' at end of input - WITS END!

Please, please, please, for the love of GOD, help me figure this out...

I have successfully used this code numerous times, now two IDEs on two computers refuse to compile it successfully. Could someone please try it with their own? I either get the "expected '}' at end of input" or a long list of errors relating to the libraries that I mostly don't understand.

Thank you, in advance, so much, for your help.


Bill Hawes.

32u4Mauze.ino (6.95 KB)

helper_3dmath.h (6.26 KB)

MPU6050.h (43.3 KB)

MPU6050_6Axis_MotionApps20.h (40.2 KB)

I2Cdev.h (12 KB)

Please do this:

  • When you encounter an error, you'll see a button on the right side of the orange bar "Copy error messages" in the Arduino IDE (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button..
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the error between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

If the text exceeds the forum's 9000 character limit, save it to a .txt file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.

File: 32u4Mauze.ino
Line: 151

Serial.print(F("DMP Initialization failed (code "));

It's got some crazy String happening. Check your quotes.

Curious why you have semicolons placed thusly:

void setup(); {...

void dmpDataReady(); {...

void loop(); {...
Serial.print(F("DMP Initialization failed (code "));

rethink the relationship between ( and" above

After commenting out three #include lines and three semicolons (See: '////////' marks) this compiled for me:

#include <MPU6050_6Axis_MotionApps20.h>
#include <helper_3dmath.h>
#include <MPU6050.h>
//////// #include <MPU6050_9Axis_MotionApps41.h>
//////// #include <Utility.h>

// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class using DMP (MotionApps v2.0)
// 6/21/2012 by Jeff Rowberg <jeff@rowberg.net>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib

// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"

#include "MPU6050_6Axis_MotionApps20.h"
//#include "MPU6050.h" // not necessary if using MotionApps include file

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#include "Wire.h"
#include "Mouse.h"
//////// #include "Utility.h"

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 mpu;
//MPU6050 mpu(0x68); // <-- use for AD0 high

/* =========================================================================
   NOTE: In addition to connection 3.3v, GND, SDA, and SCL, this sketch
   depends on the MPU-6050's INT pin being connected to the Arduino's
   external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is
   digital I/O pin 2.
   ========================================================================= */


// MPU control/status vars
bool dmpReady = false;  // set true if DMP init was successful
uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;     // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars
Quaternion q;           // [w, x, y, z]         quaternion container
VectorInt16 aa;         // [x, y, z]            accel sensor measurements
VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
VectorFloat gravity;    // [x, y, z]            gravity vector

// packet structure for InvenSense teapot demo
uint8_t teapotPacket[14] = { '

, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0x00, '\r', '\n' };

// ================================================================
// ===               INTERRUPT DETECTION ROUTINE                ===
// ================================================================

volatile bool mpuInterrupt = true;     // indicates whether MPU interrupt pin has gone high
void dmpDataReady()   //////// Removed ;
  mpuInterrupt = true;

// ================================================================
// ===                      INITIAL SETUP                       ===
// ================================================================

float euler[3];         // [psi, theta, phi]    Euler angle container
float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
float oldYPR[3];

int yawDiff;
int pitchDiff;
int rollDiff;

void setup()   //////// Removed ;


pinMode       (5, OUTPUT);
  digitalWrite  (5, HIGH);
  pinMode       (4, OUTPUT);
  digitalWrite  (4, LOW);     // Power the MPU-6050 breakout.

// join I2C bus (I2Cdev library doesn't do this automatically)
  TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz). Comment this line if having compilation difficulties with TWBR.
  Fastwire::setup(400, true);

  while (!Serial); // wait for Leonardo enumeration, others continue immediately

// initialize device
  Serial.println(F("Initializing I2C devices..."));

// verify connection
  Serial.println(F("Testing device connections..."));
  Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));

// load and configure the DMP
  Serial.println(F("Initializing DMP..."));
  devStatus = mpu.dmpInitialize();

// supply your own gyro offsets here, scaled for min sensitivity
  mpu.setZAccelOffset(1788); // 1688 factory default for my test chip

// make sure it worked (returns 0 if so)
  if (devStatus == 0)
    // turn on the DMP, now that it's ready
    Serial.println(F("Enabling DMP..."));

// enable Arduino interrupt detection
    Serial.println(F("Enabling interrupt detection (Arduino external interrupt X)..."));
    attachInterrupt(0, dmpDataReady, RISING);
    mpuIntStatus = mpu.getIntStatus();

// set our DMP Ready flag so the main loop() function knows it's okay to use it
    Serial.println(F("DMP ready! Waiting for first interrupt..."));
    dmpReady = true;

// get expected DMP packet size for later comparison
    packetSize = mpu.dmpGetFIFOPacketSize();
    // ERROR!
    // 1 = initial memory load failed
    // 2 = DMP configuration updates failed
    // (if it's going to break, usually the code will be 1)
    Serial.print(F("DMP Initialization failed (code "));

void loop()   //////// Removed ;
  if (!dmpReady) return;

// wait for MPU interrupt or extra packet(s) available
  while (!mpuInterrupt && fifoCount < packetSize)

// reset interrupt flag and get INT_STATUS byte
  mpuInterrupt = false;
  mpuIntStatus = mpu.getIntStatus();

// get current FIFO count
  fifoCount = mpu.getFIFOCount();

// check for overflow (this should never happen unless our code is too inefficient)
  if ((mpuIntStatus & 0x10) || fifoCount == 1024)
    // reset so we can continue cleanly

// otherwise, check for DMP data ready interrupt (this should happen frequently)
  else if (mpuIntStatus & 0x02)
    // wait for correct available data length, should be a VERY short wait
    while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();

// read a packet from FIFO
    mpu.getFIFOBytes(fifoBuffer, packetSize);

// track FIFO count here in case there is > 1 packet available
    // (this lets us immediately read more without waiting for an interrupt)
    fifoCount -= packetSize;

mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);

yawDiff =   ((ypr[0] - oldYPR[0]) * 1000);
    pitchDiff = ((ypr[1] - oldYPR[1]) * 1000);
    rollDiff =  ((ypr[2] - oldYPR[2]) * 1000);


oldYPR[0] = ypr[0];
    oldYPR[1] = ypr[1];
    oldYPR[2] = ypr[2];

That's tricky. My mistake.

Here I am talking about strings meanwhile, I'm counting parens.