Go Down

Topic: MPU-6050 + Servo + arduino Uno - fail when uploading (Read 4 times) previous topic - next topic

Erdin

I have seen this problem a week earlier. I don't know if it was solved.
It might have to do with a conflict between: character coding / UTF-8 / Windows / Linux.

Either the source code has wrong characters (Jeff Rowberg should fix that) or perhaps you did a copy-paste with the html code, or opened it in an editor that chanched the character coding.

I downloaded the "Raw" if this file: https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050.h
And I could not find any weird characters.

mishgass

Hi Erdin,
i re did all the steps with the libraries, and now i am getting different errors.

GYRO_Servo:13: error: 'Servo' does not name a type
GYRO_Servo.ino: In function 'void setup()':
GYRO_Servo:26: error: 'myservo' was not declared in this scope
GYRO_Servo.ino: In function 'void loop()':
GYRO_Servo:31: error: 'amp' was not declared in this scope
GYRO_Servo:31: error: expected `;' before ')' token
GYRO_Servo:36: error: 'myservo' was not declared in this scope

i hope i am not bothering you or any one els with my bigenners quaries  :)

Thanks, Mishal

Erdin

Something with the class "Servo" is missing.
Look at the examples (on the right side, click on a few examples):
http://arduino.cc/en/reference/servo
Do you have: #include <Servo.h>

Please read this:
http://forum.arduino.cc/index.php?topic=97455.0
After reading that, you can ask as many questions as you like. We like to see the whole sketch (between code tags), and you have to tell what you are talking about and how you solved it, so others can see the solution.

How did you solve the problem with the weird characters ?

Where did the file GYRO_servo.ino come from ? I have no idea what it is.


mishgass

Dear Erdin
Thank you for the heads up, and mostly thank you for pointing me to the solution, its working now.

As you suggested i had to add the [#include <Servo.h>] in my sketch, and changed the getMotion6 argument. the sketch is as follow,

[#include <Wire.h>
#include <I2Cdev.h>
#include <Servo.h>
#include <MPU6050.h>


MPU6050 mpu; // SO IT SEEMS THAT THIS STATEMENT IS ONE OF THE PROBLEMS RIGHT?

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); // this was mpu.getMotion6(&amp;ax, &amp;ay, &amp;az, &amp;gx, &amp;gy, &amp;gz);

    val = map(ay, -17000, 17000, 0, 179);
    if (val != prevVal)
    {
        myservo.write(val);
        prevVal = val;
    }

    delay(50);
}]

http://www.youtube.com/watch?v=Q8H0RE7XKEc

Once again thank you Erdin.

Erdin

Very cool indeed. Well done.
This is a good guide for balancing and filtering: http://forum.arduino.cc/index.php?topic=58048.0

Go Up