

Void Output(AccelerometerRaw raw, AccelerometerScaled scaled)

This useful method gives you the value in G thanks to the Love Electronics library.ĪccelerometerScaled scaled = accel.ReadScaledAxis() so you don't have to ReadRawAxis before you use this method). Read the *scaled* data from the accelerometer (this does it's own read from the accelerometer Read the raw data from the accelerometer.ĪccelerometerRaw raw = accel.ReadRawAxis() If(accel.IsConnected) // If we are connected to the accelerometer. Tell the accelerometer to start taking measurements. Set the range of the accelerometer to a maximum of 2G. Serial.println("Could not connect to ADX元45.") ĭigitalWrite(statusPin, LOW) // If we are not connected, turn our LED off. Check that the accelerometer is infact connected.ĭigitalWrite(statusPin, HIGH) // If we are connected, light our status LED. Create an instance of the accelerometer on the default address (0x1D) Start the I2C Wire library so we can use I2C to talk to the accelerometer. Begin by setting up the Serial Port so we can output our results. Int statusPin = 2 // I'm using digital pin 2. Set up a pin we are going to use to indicate our status using an LED. Declare a global instance of the accelerometer. Include the Love Electronics ADX元45 library so we can use the accelerometer. Include the Wire library so we can start using I2C. *ĪDX元45_Example.pde - Example sketch for integration with an ADX元45 triple axis accelerometer. I get the raw and scaled digits but want to convert one of these to degrees, I actually want to see the slope angle of the laser pointer in which i attach the adxl345 to. I use the arduino 1.0 program, and used this code
#Deg to rad how to
I wonder if someone knows how to convert the reading from adxl345 to degrees or radians.
