下面這是我使用的程式碼
// Based on I2Cdevlib, MPU6050_raw
// Experiments to verify if any data loss when writing MPU6050 outputs to EEPROM
#include "I2Cdev.h"
#include "MPU6050.h"
#include <EEPROM.h>
#include "eeprom_anything.h"
// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;
// [eeprom]
struct accelData{
int16_t ax;
int16_t ay;
int16_t az;
};
accelData acc;
int accIdx = 0;
int accMem = 0;
int max = 1024 / sizeof(acc);
void setup() {
// join I2C bus (I2Cdev library doesn't do this automatically)
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif
// 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");
}
void loop() {
//writeEEPROM();
dumpEEPROM();
}
void writeEEPROM()
{
// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
// waive the first 100 sensor data
if (accIdx >= 200 && accIdx < max + 200)
{
Serial.print("Idx: "); Serial.print(accIdx-200);
Serial.print(", ax: "); Serial.print(ax); acc.ax = ax;
Serial.print(", ay: "); Serial.print(ay); acc.ay = ay;
Serial.print(", az: "); Serial.println(az); acc.az = az;
accMem = EEPROM_writeAnything(accMem, acc);
}
accIdx ;
}
void dumpEEPROM()
{
accelData accTmp;
int tmpMem = 0;
for (int i=0; i<max; i )
{
tmpMem = EEPROM_readAnything(tmpMem, accTmp);
Serial.print("Idx: "); Serial.print(i);
Serial.print(", ax: "); Serial.print(accTmp.ax);
Serial.print(", ay: "); Serial.print(accTmp.ay);
Serial.print(", az: "); Serial.println(accTmp.az);
}
}
這是我出現的error
MPU6050_EEPROM:20: error: 'T' does not name a type
MPU6050_EEPROM:20: error: ISO C++ forbids declaration of 'value' with no type [-fpermissive]
MPU6050_EEPROM:21: error: 'T' has not been declared
'T' does not name a type
跪求各位大神幫幫我~~~~