Help with control from Arduino Mega to ADXL345 Accelerometer

Click For Summary
The user is experiencing a compilation error while trying to run code for an Arduino Mega that interfaces with an ADXL345 accelerometer. The specific error message indicates an "undefined reference to `yield`" in the wiring.c file. This issue may stem from using an outdated version of the Arduino IDE, as the code requires a more recent version that supports the necessary libraries. The user is following a tutorial that includes I2C communication setup and data reading from the accelerometer. Assistance is requested to resolve the compilation error and successfully run the project.
NaughtyBear
Messages
17
Reaction score
1
So I was starting a project and have run into a small issue. I was following a tutorial and the code is not compiling correctly. The error reads as:

Arduino: 1.6.3 (Windows 8.1), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\NEVERM~1\AppData\Local\Temp\build4347706786189926824.tmp/core.a(wiring.c.o): In function `delay':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/wiring.c:113: undefined reference to `yield'

collect2.exe: error: ld returned 1 exit status

Error compiling.And I am unsure of what that means or what I am doing wrong. The link is http://eeenthusiast.com/arduino-i2c-adxl-345-robot/ is the tutorial I was following and the code is:
Code:
#include <Wire.h>

#define accel_module (0x53)
byte values[6] ;
char output[512];

void setup(){
Wire.begin();
Serial.begin(9600);

Wire.beginTransmission(accel_module);
Wire.write(0x2D);
Wire.write(0);
Wire.endTransmission();
Wire.beginTransmission(accel_module);
Wire.write(0x2D);
Wire.write(16);
Wire.endTransmission();
Wire.beginTransmission(accel_module);
Wire.write(0x2D);
Wire.write(8);
Wire.endTransmission();
}

void loop(){
int xyzregister = 0x32;
int x, y, z;

Wire.beginTransmission(accel_module);
Wire.write(xyzregister);
Wire.endTransmission();

Wire.beginTransmission(accel_module);
Wire.requestFrom(accel_module, 6);

int i = 0;
while(Wire.available()){
values[i] = Wire.read();
i++;
}
Wire.endTransmission();

x = (((int)values[1]) << 8) | values[0];
y = (((int)values[3])<< 8) | values[2];
z = (((int)values[5]) << 8) | values[4];

sprintf(output, "%d %d %d", x, y, z);
Serial.print(output);
Serial.write(10);

delay(2000);
}

Any and all help is appreciated. Thank you for your time and assistance!
 
Engineering news on Phys.org
I am trying to understand how transferring electric from the powerplant to my house is more effective using high voltage. The suggested explanation that the current is equal to the power supply divided by the voltage, and hence higher voltage leads to lower current and as a result to a lower power loss on the conductives is very confusing me. I know that the current is determined by the voltage and the resistance, and not by a power capability - which defines a limit to the allowable...

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
Replies
11
Views
24K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 1 ·
Replies
1
Views
4K