Hey, and thank you very much for providing such a great software, but now i got a problem:
Im working with an MPU-6050 sensorboard and wanted to run the basic raw data output sketch but I have compiling issues :/
Here's my error output:
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_init':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:76:16: error: 'SDA' undeclared (first use in this function)
digitalWrite(SDA, 1);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:76:16: note: each undeclared identifier is reported only once for each function it appears in
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:77:16: error: 'SCL' undeclared (first use in this function)
digitalWrite(SCL, 1);
^
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:7: error: 'TWSR' undeclared (first use in this function)
cbi(TWSR, TWPS0);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:3: note: in expansion of macro 'cbi'
cbi(TWSR, TWPS0);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:13: error: 'TWPS0' undeclared (first use in this function)
cbi(TWSR, TWPS0);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:3: note: in expansion of macro 'cbi'
cbi(TWSR, TWPS0);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:81:13: error: 'TWPS1' undeclared (first use in this function)
cbi(TWSR, TWPS1);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:81:3: note: in expansion of macro 'cbi'
cbi(TWSR, TWPS1);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:82:3: error: 'TWBR' undeclared (first use in this function)
TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:3: error: 'TWCR' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
^
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:14: error: 'TWEN' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:26: error: 'TWIE' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:38: error: 'TWEA' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_disable':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:3: error: 'TWCR' undeclared (first use in this function)
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
^
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:17: error: 'TWEN' undeclared (first use in this function)
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:29: error: 'TWIE' undeclared (first use in this function)
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:41: error: 'TWEA' undeclared (first use in this function)
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:105:16: error: 'SDA' undeclared (first use in this function)
digitalWrite(SDA, 0);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:106:16: error: 'SCL' undeclared (first use in this function)
digitalWrite(SCL, 0);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_setAddress':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:118:3: error: 'TWAR' undeclared (first use in this function)
TWAR = address << 1;
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_setFrequency':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:129:3: error: 'TWBR' undeclared (first use in this function)
TWBR = ((F_CPU / frequency) - 16) / 2;
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_readFrom':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:187:7: error: 'TWDR' undeclared (first use in this function)
TWDR = twi_slarw;
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:188:13: error: 'TWCR' undeclared (first use in this function)
} while(TWCR & _BV(TWWC));
^
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:188:24: error: 'TWWC' undeclared (first use in this function)
} while(TWCR & _BV(TWWC));
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:16: error: 'TWINT' undeclared (first use in this function)
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:29: error: 'TWEA' undeclared (first use in this function)
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:41: error: 'TWEN' undeclared (first use in this function)
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:53: error: 'TWIE' undeclared (first use in this function)
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:193:65: error: 'TWSTA' undeclared (first use in this function)
const int mpu_adress = 0x68; // I2C adress of the MPU-6050
int16_t acc_x, acc_y, acc_z; // Variables for accelerometer raw data
int16_t gyro_x, gyro_y, gyro_z; // Variables for gyroscope raw data
int16_t temp; // Variable for temperature data
char tmp_str[7]; // Temporary variable for converting function
char* convert_int16_to_str(int16_t i) // Converts int16 to string. Here used to get strings with the same length in the debug window.
{
sprintf(tmp_str, "%6d", i);
return tmp_str;
}
void setup()
{
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(mpu_adress); // Begins a transmission to the I2C slave (MPU-6050)
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
}
void loop()
{
Wire.beginTransmission(mpu_adress);
Wire.write(0x3B); // Starting with register 0x3B (ACCEL_XOUT_H) [Register Map and Descriptions Revision 4.2, p.40]
Wire.endTransmission(false); // Arduino will send a restart, thus keeping the connection active
Wire.requestFrom(mpu_adress, 72, true); // Request all 14 registers (72=14)
// Here, two registers are read and stored in the same variable
acc_x = Wire.read() << 8 | Wire.read(); // reading registers: 0x3B (ACCEL_XOUT_H) and 0x3C (ACCEL_XOUT_L)
acc_y = Wire.read() << 8 | Wire.read(); // reading registers: 0x3D (ACCEL_YOUT_H) and 0x3E (ACCEL_YOUT_L)
acc_z = Wire.read() << 8 | Wire.read(); // reading registers: 0x3F (ACCEL_ZOUT_H) and 0x40 (ACCEL_ZOUT_L)
temp = Wire.read() << 8 | Wire.read(); // reading registers: 0x41 (TEMP_OUT_H) and 0x42 (TEMP_OUT_L)
gyro_x = Wire.read() << 8 | Wire.read(); // reading registers: 0x43 (GYRO_XOUT_H) and 0x44 (GYRO_XOUT_L)
gyro_y = Wire.read() << 8 | Wire.read(); // reading registers: 0x45 (GYRO_YOUT_H) and 0x46 (GYRO_YOUT_L)
gyro_z = Wire.read() << 8 | Wire.read(); // reading registers: 0x47 (GYRO_ZOUT_H) and 0x48
//Data is printed to the Debug Window
Serial.print(" | aX = "); Serial.print(convert_int16_to_str(acc_x));
Serial.print(" | aY = "); Serial.print(convert_int16_to_str(acc_y));
Serial.print(" | aZ = "); Serial.print(convert_int16_to_str(acc_z));
Serial.print(" | gX = "); Serial.print(convert_int16_to_str(gyro_x));
Serial.print(" | gY = "); Serial.print(convert_int16_to_str(gyro_y));
Serial.print(" | gZ = "); Serial.print(convert_int16_to_str(gyro_z));
Serial.print(" | tmp = "); Serial.print(temp/340.00+36.53);
Serial.println();
delay(1000);
}
I really hope you can help me with this and that i don't annoy you with a possibly very simple problem.
I just recently started working with the Arduino Uno R3 and have no previous experience but a lot of motivation. ^^
The 16u2 has no I2C interface. Only Serial and SPI as far as I know. You possibly also missunderstood how Hoodloader2 works, so please check the docs again. You are dealing with 2 Microcontrollers now.
Hey, and thank you very much for providing such a great software, but now i got a problem:
Im working with an MPU-6050 sensorboard and wanted to run the basic raw data output sketch but I have compiling issues :/
Here's my error output:
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_init':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:76:16: error: 'SDA' undeclared (first use in this function)
digitalWrite(SDA, 1);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:76:16: note: each undeclared identifier is reported only once for each function it appears in
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:77:16: error: 'SCL' undeclared (first use in this function)
digitalWrite(SCL, 1);
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:7: error: 'TWSR' undeclared (first use in this function)
cbi(TWSR, TWPS0);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:3: note: in expansion of macro 'cbi'
cbi(TWSR, TWPS0);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:13: error: 'TWPS0' undeclared (first use in this function)
cbi(TWSR, TWPS0);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:3: note: in expansion of macro 'cbi'
cbi(TWSR, TWPS0);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:81:13: error: 'TWPS1' undeclared (first use in this function)
cbi(TWSR, TWPS1);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:81:3: note: in expansion of macro 'cbi'
cbi(TWSR, TWPS1);
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:82:3: error: 'TWBR' undeclared (first use in this function)
TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:3: error: 'TWCR' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
^
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:14: error: 'TWEN' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:26: error: 'TWIE' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:38: error: 'TWEA' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_disable':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:3: error: 'TWCR' undeclared (first use in this function)
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
^
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:17: error: 'TWEN' undeclared (first use in this function)
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:29: error: 'TWIE' undeclared (first use in this function)
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:41: error: 'TWEA' undeclared (first use in this function)
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:105:16: error: 'SDA' undeclared (first use in this function)
digitalWrite(SDA, 0);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:106:16: error: 'SCL' undeclared (first use in this function)
digitalWrite(SCL, 0);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_setAddress':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:118:3: error: 'TWAR' undeclared (first use in this function)
TWAR = address << 1;
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_setFrequency':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:129:3: error: 'TWBR' undeclared (first use in this function)
TWBR = ((F_CPU / frequency) - 16) / 2;
^
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_readFrom':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:187:7: error: 'TWDR' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:188:13: error: 'TWCR' undeclared (first use in this function)
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:188:24: error: 'TWWC' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:16: error: 'TWINT' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:29: error: 'TWEA' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:41: error: 'TWEN' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:53: error: 'TWIE' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:193:65: error: 'TWSTA' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_writeTo':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:269:7: error: 'TWDR' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:270:13: error: 'TWCR' undeclared (first use in this function)
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:270:24: error: 'TWWC' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:271:16: error: 'TWINT' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:271:29: error: 'TWEA' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:271:41: error: 'TWEN' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:271:53: error: 'TWIE' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:275:65: error: 'TWSTA' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_reply':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:5: error: 'TWCR' undeclared (first use in this function)
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:16: error: 'TWEN' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:28: error: 'TWIE' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:40: error: 'TWINT' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:53: error: 'TWEA' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_stop':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:3: error: 'TWCR' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
^
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:14: error: 'TWEN' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:26: error: 'TWIE' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:38: error: 'TWEA' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:50: error: 'TWINT' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:63: error: 'TWSTO' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_releaseBus':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:3: error: 'TWCR' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
^
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:14: error: 'TWEN' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:26: error: 'TWIE' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:38: error: 'TWEA' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:50: error: 'TWINT' undeclared (first use in this function)
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\compat\twi.h:36:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'TWI_vect':
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWSR' undeclared (first use in this function)
switch(TW_STATUS){
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS7' undeclared (first use in this function)
switch(TW_STATUS){
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS6' undeclared (first use in this function)
switch(TW_STATUS){
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS5' undeclared (first use in this function)
switch(TW_STATUS){
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS4' undeclared (first use in this function)
switch(TW_STATUS){
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS3' undeclared (first use in this function)
switch(TW_STATUS){
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:406:7: error: 'TWDR' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:426:4: error: 'TWCR' undeclared (first use in this function)
In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:426:15: error: 'TWINT' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:426:28: error: 'TWSTA' undeclared (first use in this function)
D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:426:40: error: 'TWEN' undeclared (first use in this function)
exit status 1 Error compiling for board HoodLoader2 16u2.
And this is the Sketch i wrote, heavily inspired by this one: http://www.mschoeffler.de/2017/10/05/tutorial-how-to-use-the-gy-521-module-mpu-6050-breakout-board-with-the-arduino-uno/
// (c) Michael Moser 2017
include "Wire.h" // Lib for I2C communication
const int mpu_adress = 0x68; // I2C adress of the MPU-6050
int16_t acc_x, acc_y, acc_z; // Variables for accelerometer raw data int16_t gyro_x, gyro_y, gyro_z; // Variables for gyroscope raw data int16_t temp; // Variable for temperature data
char tmp_str[7]; // Temporary variable for converting function
char* convert_int16_to_str(int16_t i) // Converts int16 to string. Here used to get strings with the same length in the debug window. { sprintf(tmp_str, "%6d", i); return tmp_str; }
void setup() { Serial.begin(9600); Wire.begin(); Wire.beginTransmission(mpu_adress); // Begins a transmission to the I2C slave (MPU-6050) Wire.write(0x6B); // PWR_MGMT_1 register Wire.write(0); // set to zero (wakes up the MPU-6050) Wire.endTransmission(true);
}
void loop() { Wire.beginTransmission(mpu_adress); Wire.write(0x3B); // Starting with register 0x3B (ACCEL_XOUT_H) [Register Map and Descriptions Revision 4.2, p.40] Wire.endTransmission(false); // Arduino will send a restart, thus keeping the connection active Wire.requestFrom(mpu_adress, 72, true); // Request all 14 registers (72=14)
// Here, two registers are read and stored in the same variable acc_x = Wire.read() << 8 | Wire.read(); // reading registers: 0x3B (ACCEL_XOUT_H) and 0x3C (ACCEL_XOUT_L) acc_y = Wire.read() << 8 | Wire.read(); // reading registers: 0x3D (ACCEL_YOUT_H) and 0x3E (ACCEL_YOUT_L) acc_z = Wire.read() << 8 | Wire.read(); // reading registers: 0x3F (ACCEL_ZOUT_H) and 0x40 (ACCEL_ZOUT_L) temp = Wire.read() << 8 | Wire.read(); // reading registers: 0x41 (TEMP_OUT_H) and 0x42 (TEMP_OUT_L) gyro_x = Wire.read() << 8 | Wire.read(); // reading registers: 0x43 (GYRO_XOUT_H) and 0x44 (GYRO_XOUT_L) gyro_y = Wire.read() << 8 | Wire.read(); // reading registers: 0x45 (GYRO_YOUT_H) and 0x46 (GYRO_YOUT_L) gyro_z = Wire.read() << 8 | Wire.read(); // reading registers: 0x47 (GYRO_ZOUT_H) and 0x48
//Data is printed to the Debug Window Serial.print(" | aX = "); Serial.print(convert_int16_to_str(acc_x)); Serial.print(" | aY = "); Serial.print(convert_int16_to_str(acc_y)); Serial.print(" | aZ = "); Serial.print(convert_int16_to_str(acc_z)); Serial.print(" | gX = "); Serial.print(convert_int16_to_str(gyro_x)); Serial.print(" | gY = "); Serial.print(convert_int16_to_str(gyro_y)); Serial.print(" | gZ = "); Serial.print(convert_int16_to_str(gyro_z)); Serial.print(" | tmp = "); Serial.print(temp/340.00+36.53); Serial.println();
delay(1000);
}
I really hope you can help me with this and that i don't annoy you with a possibly very simple problem. I just recently started working with the Arduino Uno R3 and have no previous experience but a lot of motivation. ^^
Greetings, Mike.