Help with control from Arduino Mega to ADXL345 Accelerometer

Click For Summary
SUMMARY

The forum discussion addresses a compilation error encountered while programming an Arduino Mega 2560 to interface with an ADXL345 accelerometer. The error message indicates an "undefined reference to `yield`" in the Arduino IDE version 1.6.3 on Windows 8.1. This issue arises from the lack of a proper yield function in the code, which is necessary for certain libraries to function correctly. Users are advised to ensure that the Arduino core libraries are correctly installed and to check for any missing dependencies in the project setup.

PREREQUISITES
  • Familiarity with Arduino IDE version 1.6.3
  • Understanding of I2C communication protocols
  • Basic knowledge of C/C++ programming
  • Experience with Arduino Mega 2560 hardware
NEXT STEPS
  • Research how to implement the `yield` function in Arduino sketches
  • Explore the Arduino Wire library documentation for I2C communication
  • Learn about troubleshooting common Arduino compilation errors
  • Investigate the ADXL345 accelerometer datasheet for advanced configuration options
USEFUL FOR

This discussion is beneficial for hobbyists, embedded systems developers, and anyone working with Arduino projects involving I2C sensors like the ADXL345 accelerometer.

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

Similar threads

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