Loading...
Pages: [1]   Go Down
Author Topic: Unable to program arduino Uno to use MPU6050 unit ERRor  (Read 295 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I'm having problem uploading the code to arduino uno... the error below appears everytime...
can someone help to rectify this issue.. thanx


Code:
// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class
// 10/7/2011 by Jeff Rowberg <jeff@rowberg.net>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
//     2011-10-07 - initial release

/* ============================================
I2Cdev device library code is placed under the MIT license
Copyright (c) 2011 Jeff Rowberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================
*/

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

// 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.h"

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 accelgyro;

int16_t ax, ay, az;
int16_t gx, gy, gz;

#define LED_PIN 13
bool blinkState = false;

void setup() {
    // join I2C bus (I2Cdev library doesn't do this automatically)
    Wire.begin();

    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(38400);

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

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

    // configure Arduino LED for
    pinMode(LED_PIN, OUTPUT);
}

void loop() {
    // read raw accel/gyro measurements from device
    accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

    // these methods (and a few others) are also available
    //accelgyro.getAcceleration(&ax, &ay, &az);
    //accelgyro.getRotation(&gx, &gy, &gz);

    // display tab-separated accel/gyro x/y/z values
    Serial.print("a/g:\t");
    Serial.print(ax); Serial.print("\t");
    Serial.print(ay); Serial.print("\t");
    Serial.print(az); Serial.print("\t");
    Serial.print(gx); Serial.print("\t");
    Serial.print(gy); Serial.print("\t");
    Serial.println(gz);

    // blink LED to indicate activity
    blinkState = !blinkState;
    digitalWrite(LED_PIN, blinkState);
}

Quote
MPU6050_raw:1: error: stray '\' in program
In file included from MPU6050_raw.ino:38:
C:\Users\ahmed\Documents\Arduino\libraries\I2Cdev/I2Cdev.h:1: error: stray '\357' in program
C:\Users\ahmed\Documents\Arduino\libraries\I2Cdev/I2Cdev.h:1: error: stray '\273' in program
C:\Users\ahmed\Documents\Arduino\libraries\I2Cdev/I2Cdev.h:1: error: stray '\277' in program
In file included from MPU6050_raw.ino:39:
C:\Users\ahmed\Documents\Arduino\libraries\MPU6050/MPU6050.h:1: error: stray '\357' in program
C:\Users\ahmed\Documents\Arduino\libraries\MPU6050/MPU6050.h:1: error: stray '\273' in program
C:\Users\ahmed\Documents\Arduino\libraries\MPU6050/MPU6050.h:1: error: stray '\277' in program
In file included from C:\Users\ahmed\Documents\Arduino\libraries\MPU6050/MPU6050.h:40,
                 from MPU6050_raw.ino:39:
C:\Users\ahmed\Documents\Arduino\libraries\I2Cdev/I2Cdev.h:1: error: stray '\357' in program
C:\Users\ahmed\Documents\Arduino\libraries\I2Cdev/I2Cdev.h:1: error: stray '\273' in program
C:\Users\ahmed\Documents\Arduino\libraries\I2Cdev/I2Cdev.h:1: error: stray '\277' in program
In file included from MPU6050_raw.ino:34:
C:\Users\ahmed\Desktop\arduino-1.0.3-windows\arduino-1.0.3\libraries\Wire/Wire.h:30: error: expected constructor, destructor, or type conversion before 'class'

Logged

Global Moderator
UK
Online Online
Brattain Member
*****
Karma: 137
Posts: 19006
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You've copied the code from a website, and it has illegal characters in it.
I'd copy it into an editor like Notepad++, and use that to sniff out and eliminate the illegal characters.
Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you please specify the illegal characters...
i have already converted the files to ANSI Encoding... after copying from the website...it doesn't seem to work.
Logged

Offline Offline
God Member
*****
Karma: 27
Posts: 827
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had that happen with code I copied from a website and ended up having to go into a hex editor to get rid of it. When you look in the hex editor you will see it right away as the first byte.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 311
Posts: 35470
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code you posted above does not compile, for me, because I don't have any of the libraries it includes. But, it does not generate any messages about stray \ characters. So, the issue is in the libraries, not the sketch.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you please tell how to add this library.. to resolve this issue... i created a the missing library folders in \Documents\Arduino\libraries folder.. n copied the files to it, it doesn't seem to work..

https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050
this is the original site i got the code from...
Logged

Offline Offline
God Member
*****
Karma: 27
Posts: 827
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use this link instead and click on "ZIP"
https://github.com/jrowberg/i2cdevlib

This will actually download all the files instead trying to copy and paste them which is what is causing your problem.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 311
Posts: 35470
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have I ever mentioned that I hate github. That has got to be the crappiest excuse for a web interface in the history of the internet. If you click the Code link, you can download a zip file.

Doing that, extracting the libraries, and pasting your code into the IDE again results in just one "error" message:
Quote
Binary sketch size: 6,330 bytes (of a 30,720 byte maximum)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much guys... it's finally working..  smiley-lol
Logged

Pages: [1]   Go Up
Print
 
Jump to: