The main example code was kept very simple. More detailed information of the sensing functions and interrupts can be found on the ADX元45 Datasheet. The comments can help guide you as to what each function does along with recommended ranges to stay within where applicable. attachInterrupt(digitalPinToInterrupt(interruptPin), ADXL_ISR, RISING) // Attach Interrupt
![labview arduino i2c example labview arduino i2c example](https://3.bp.blogspot.com/-2D_0B78kqP0/Td4B_id3CdI/AAAAAAAAADE/AEzq4gSG7mY/s1600/Schematic.png)
Turn on Interrupts for each mode (1 = ON, 0 = OFF) This library may have a problem using INT2 pin. This chooses the pin on the ADX元45 to use for Interrupts. Accepts only 1 or 2 values for pins INT1 and INT2. tImportantInterruptMapping(1, 1, 1, 1, 1) // Sets "tEveryInterruptMapping(single tap, double tap, free fall, activity, inactivity) " Setting all interupts to take place on INT1 pin Set values for what is considered FREE FALL (0-255)Īdxl.setFreeFallThreshold(7) // (5 - 9) recommended - 62.5mg per incrementĪdxl.setFreeFallDuration(30) // (20 - 70) recommended - 5ms per increment Set values for what is considered a TAP and what is a DOUBLE TAP (0-255)Īdxl.setTapThreshold(50) // 62.5 mg per incrementĪdxl.setTapDuration(15) // 625 μs per incrementĪdxl.setDoubleTapLatency(80) // 1.25 ms per incrementĪdxl.setDoubleTapWindow(200) // 1.25 ms per increment SPI pins on the ATMega328: 11, 12 and 13 as reference in SPI LibraryĪdxl.setActivityXYZ(1, 0, 0) // Set to activate movement detection in the axes "tActivityXYZ(X, Y, Z) " (1 = ON, 0 = OFF)Īdxl.setActivityThreshold(75) // 62.5mg per increment // Set activity // Inactivity thresholds (0-255)Īdxl.setInactivityXYZ(1, 0, 0) // Set to detect inactivity in all the axes "tInactivityXYZ(X, Y, Z) " (1 = ON, 0 = OFF)Īdxl.setInactivityThreshold(75) // 62.5mg per increment // Set inactivity // Inactivity thresholds (0-255)Īdxl.setTimeInactivity(10) // How many seconds of no activity is inactive?Īdxl.setTapDetectionOnXYZ(0, 0, 1) // Detect taps in the directions turned ON "tTapDetectionOnX(X, Y, Z) " (1 = ON, 0 = OFF) Higher Values = Wider Measurement RangeĪdxl.setSpiBit(0) // Configure the device to be in 4 wire SPI mode when set to '0' or 3 wire SPI mode when set to 1 Serial.println("SparkFun ADX元45 Accelerometer Hook Up Guide Example") Īdxl.setRangeSetting(16) // Give the range settings Serial.begin(9600) // Start the serial terminal This is where you'll be able to configure your settings and sensing feature thresholds. The most complex part of the example code is the void setup() section. By default, the code has you utilizing SPI communication. Make sure to comment out // the line of code you are not using. ADX元45 adxl = ADX元45() // USE FOR I2C COMMUNICATION
![labview arduino i2c example labview arduino i2c example](http://www.armlearning.com/wp-content/uploads/2018/01/arm-due-and-i2c-lcd_bb.png)
* Comment Out The One You Are Not Using */ĪDX元45 adxl = ADX元45(10) // USE FOR SPI COMMUNICATION, ADX元45(CS_PIN) This is where you will let the library know whether you have setup your hardware for SPI or I2C communication. The first important selection to make is under the COMMUNICATION SECTION. Now that you have the example sketch open, let's go through and take a look at all the ways we can customize the ADX元45. Applicationsīelow you can reference the ADX元45 breakout board and pin functions.
![labview arduino i2c example labview arduino i2c example](https://pinoutguide.com/visual/gen/snescontroller.jpg)
Furthermore, low power modes enable intelligent motion-based power management with threshold sensing and active acceleration measurement at extremely low power dissipation. Its high resolution (4 mg/LSB) enables measurement of inclination changes less than 1.0°. The ADX元45 is well suited to measure the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. An integrated, patent pending 32-level first in, first out (FIFO) buffer can be used to store data to minimize host processor intervention. These functions can also be mapped to one of two interrupt output pins. All thresholds levels that trigger the activity, free-fall, and single tap/double tap events are user-set levels. Free-fall sensing compares the acceleration on all axes with the threshold value to know if the device is falling. Activity and inactivity sensing detect the presence or lack of motion. Whoa! What are those last three?! Yes, the ADX元45 has special sensing abilities! The single and double tap sensing detects when a single, or two simultaneous, acceleration events occur. Ultra Low Power: As low as 23 uA in measurement mode, 0.1uA in standby mode at 2.5V.