0
這是我的代碼:錯誤採用Atmel Studio 6中,爲Atmega2560建設項目時(與HMC5883L,MPU6050和I2Cdev libararies)
#include <Wire.h>
#include <I2Cdev.h>
#include <HMC5883L.h>
#include <MPU6050.h>
#include "Arduino.h"
void setup();
void loop();
MPU6050 accelgyro;
HMC5883L mag;
int16_t mx, my, mz;
void setup() {
Wire.begin();
accelgyro.initialize();
accelgyro.setI2CBypassEnabled(true);
Serial.begin(9600);
// initialize device
Serial.println("Initializing I2C devices...");
mag.initialize();
// verify connection
Serial.println("Testing device connections...");
Serial.println(mag.testConnection() ? "HMC5883L connection successful" : "HMC5883L connection failed");
}
void loop() {
mag.getHeading(&mx, &my, &mz);
Serial.print("mag:\t");
Serial.print(mx); Serial.print("\t");
Serial.print(my); Serial.print("\t");
Serial.print(mz); Serial.print("\t");
float heading = atan2(my, mx);
if(heading < 0)
heading += 2 * M_PI;
Serial.print("heading:\t");
Serial.println(heading * 180/M_PI);
}
它可以在Arduino的IDE工作。 以下是Atmel Studio 6中的警告(2個未初始化的警告和4個由I2Cdev庫生成的警告),沒有錯誤。
warning 5 **'progBuffer' may be used uninitialized in this function [-Wuninitialized]** D:/Program Files (x86)/Arduino/libraries/MPU6050/MPU6050.cpp 2971 14 HMC
warning 6 **'progBuffer' may be used uninitialized in this function [-Wuninitialized]** D:/Program Files (x86)/Arduino/libraries/MPU6050/MPU6050.cpp 3076 101 HMC
warning 4 **#warning - Timeout detection (some Wire requests block forever) [-Wcpp]** D:/Program Files (x86)/Arduino/libraries/I2Cdev/I2Cdev.cpp 67 14 HMC
warning 2 **#warning Arduino IDE v1.0.1+ with I2CDEV_BUILTIN_FASTWIRE implementation is recommended. [-Wcpp]** D:/Program Files (x86)/Arduino/libraries/I2Cdev/I2Cdev.cpp 65 14 HMC
warning 3 **#warning This I2Cdev implementation does not support: [-Wcpp]** D:/Program Files (x86)/Arduino/libraries/I2Cdev/I2Cdev.cpp 66 14 HMC
warning 1 **#warning Using current Arduino IDE with Wire library is functionally limiting. [-Wcpp]** D:/Program Files (x86)/Arduino/libraries/I2Cdev/I2Cdev.cpp 64 14 HMC
這裏是輸出:
collect2: ld returned 1 exit status
make: *** [HMC.elf] Error 1
誰能幫我?非常感謝!!
嗨,謝謝你的回答!其實唯一的問題是這個錯誤1,它沒有給我任何其他問題或錯誤。我想使用AS6的原因是我需要爲atMega 2560使用freeRTOS,並且我沒有爲Arduino IDE找到一個好的版本,你有什麼好主意?謝謝你! – deciding 2014-09-29 09:09:38
不是我在答案中發佈的內容:爲了追蹤問題,您需要找到連接器錯誤消息。沒有這個,我不明白你的問題如何回答。 – kebs 2014-09-29 15:37:02