GY-521 on Mega2560

I am new to Arduino and have run into a problem with the ADXL3 sensor example as i have a GY-521 and a Mega2560. The example uses a UNO and ADLx3 which gives strange results when i run the sample code. I have searched through the web for GY-521 on a Mega2560 but all of the examples and wire configurations, although they compile with no errors, all have the same issue. When i move the GY-521 the printout does not display the changes in x, y and z. It just keeps repeating the same values.

I am looking for code and wiring that actually work.

Please help.

Have you tried the examples from this reference library;

Thanks. Much appreciated.

I ran the test program and received a message saying

15:59:30.540 -> C:\Elegoo\Testlib\GY521-0.3.6\GY521-0.3.6\examples\test1\test1.ino
15:59:30.681 -> 102 Could not connect to GY521
15:59:31.665 -> 1102 Could not connect to GY521
15:59:32.650 -> 2104 Could not connect to GY521
15:59:33.681 -> 3104 Could not connect to GY521
15:59:34.665 -> 4105 Could not connect to GY521

Is it a problem with my pins. I have the following connections:

  GY-521                   Mega 2560 ver 3
      VCC                                      3.5 Volt
      GND                                     GND
       SCL                                      SCL
        SCD                                     SCD

it seems that i stumbled on to the problem. I changed the sensor to 0x68 from 0x69 and now it is functioning.

When I did that it said this

14:39:14.027 -> C:\Users\z gx gy gz T
14:39:14.027 -> 0 0 0 1 -4 0 0 22
14:39:14.027 -> -521.ino
14:39:14.027 -> GY521_LIB_VERSION: 0.3.7
14:39:14.027 -> start...
14:39:14.027 ->
14:39:14.027 -> ACCELEROMETER GYROSCOPE TEMPERATURE
14:39:14.027 -> ax ay az gx gy gz T
14:39:14.027 -> 0 0 0 1 -4 0 0 22
14:39:14.949 -> ⸮⸮|/⸮⸮⸮F⸮
14:39:15.041 -> ⸮⸮⸮

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.