Using the ADXL345

I cant find any links that are not broken in reference to the KOP accelerometer from a few years back. I was going to use a gyro but drift is to irritating to compensate for, so a digital accelerometer is the next best thing. Does anyone know how to program for these ( no examples could be found in this years software) and how to wire it? I see a 0v SDA and SCL and 5v, how is this wired?

EDIT: I found an up to date 2016 screensteps page, but it still has broken links to the wiring page. the I2C has a 3.3v port and the accel I have says 5v on it, will this work? Also my electrical guy thinks I can use this accelerometer to measure angle. Is this true?

Next best thing to do what, exactly?

If you’re thinking about double-integrating acceleration to get yaw angle, you’ll be disappointed.

What do you suggest? I was planning on using limit switches if not gyro. I have a mechanism in the center of the robot that has 2 windows motors that rotate the shooter scoop, on the end of this rotatable shooter scoop I have the gyro. I have also put 2 limit switches at the upper and lowermost positions that are preferred to this device.
Visual aid:
This isnt the bot I have but its similar to that mechanism in the middle.

Are you trying to tell what angle the shooter is at? You could just use an encoder to tell you what angle the shooter is at relative to the robot. An accelerometer isn’t going to work very well to detect what angle you are at, you’d be better off using the gyro.

*Can you clearly describe what you are trying to accomplish? You will get more accurate advice that way.

I want to be able to click a button on my joystick and have my mechanism rotate to a high point, then also be able to click a second button to set the rotation to a low point. I could do this with time, problem is, the mechanism is quite heavy on the far ends, so the drop time is largely influenced by gravity, but the lift time is much more reliable.

I would suggest trying the accelerometer and see how well it works out, but without any integrating etc. To calculate the angle just use atan2( y, x ) where the two accelerometer axes are in the plane of rotation. Turns out that gravity is a very well-defined “down” vector that will move along the axes. Of course this will only work accurately when the arm is relatively stationary (not experiencing other accelerations relative to g) so you might need to move the arm more slowly when taking measurements. I’ll be curious to hear if it works.

For what it’s worth, gyros are much more accurate in the pitch rotation, which you’re attempting to do, at least if you have a smart gyro.

The best option is to use an encoder. You would attach an encoder to the shaft that rotates, and would not only be able to tell when it is at the endpoints, but exactly where it is, to a far higher degree of accuracy than would be possible with a gyro or accelerometer. You could even pair this with a PID loop to get it to hold position, we implemented something similar here:

If you would like additional information about the ADXL345, the original data sheets can be found here: