Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help with control from Arduino Mega to ADXL345 Accelerometer

  1. Jul 19, 2015 #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 (Text):
    #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!
     
  2. jcsd
  3. Jul 19, 2015 #2
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Help with control from Arduino Mega to ADXL345 Accelerometer
Loading...