If ☒g is selected, the accelerometer can now detect acceleration up to ☑9.6 m/s 2 (2 * 9.8). This prints out the current range of the ADX元45. The last function is the displayRange() function: void displayRange(void) The datarate can be any of the following: ADX元45_DATARATE_3200_HZįor example, to change the data rate to 400 Hz, place this inside setup(), after accel.begin(): tDataRate(ADX元45_DATARATE_400_HZ) To change data rate, use the function setDataRate(datarate). The Arduino UNO supports high-speed I2C mode which has a speed of 3.4 MHz so it will not have trouble at higher data rates. This means rate selection is dependent on the speed of the microcontroller device. Selecting too high of an output data rate with a low communication speed results in samples being discarded. The datasheet tells us about data rate selection:Īn output data rate should be selected that is appropriate for the communication protocol and frequency selected. This also gives us the usable data rates from the slowest (10 Hz) to the fastest (3200 Hz). This function returns the current data rate of the ADX元45. The next function is getDataRate(): void displayDataRate(void) This function is responsible for this part of the output on the serial monitor: Sensor: ADX元45 This function displays the sensor type, maximum and minimum values, resolution and other information about the ADX元45. The first function is the displaySensorDetails() function: void displaySensorDetails(void) The sensortest sketch comes with three functions beside the usual setup() and loop(). Explaining the Sketch Display Sensor Details The library converts the output to m/s 2 instead of g units. Upload the sketch to your Arduino and open Serial Monitor. To use this sketch, follow this wiring diagram:įor other boards, make sure that this connection is followed: Arduino Pin Serial.print("Z: ") Serial.print() Serial.print(" ") Serial.println("m/s^2 ") Serial.print("Y: ") Serial.print() Serial.print(" ") Serial.print("X: ") Serial.print() Serial.print(" ") * Display the results (acceleration is measured in m/s^2) */ * Display additional settings (outside the scope of sensor_t) */ * Display some basic information on this sensor */ * Set the range to whatever is appropriate for your project */ Serial.println("Ooops, no ADX元45 detected. * There was a problem detecting the ADX元45. Serial.println("Accelerometer Test") Serial.println("") While (!Serial) // for Leonardo/Micro/Zero ![]() Serial.print ("Resolution: ") Serial.print(sensor.resolution) Serial.println(" m/s^2") Serial.print ("Min Value: ") Serial.print(sensor.min_value) Serial.println(" m/s^2") Serial.print ("Max Value: ") Serial.print(sensor.max_value) Serial.println(" m/s^2") Serial.print ("Unique ID: ") Serial.println(nsor_id) Serial.print ("Driver Ver: ") Serial.println(sensor.version) Serial.print ("Sensor: ") Serial.println(sensor.name) * Assign a unique ID to this sensor at the same time */Īdafruit_ADX元45_Unified accel = Adafruit_ADX元45_Unified(12345) The example sketch is as shown: #include We also need to install the Unified Sensor library:Īfter installation of the libraries, go to Files > Examples > Adafruit ADX元45 > sensortest. On the search field, type "Adafruit ADX元45", press enter and the library should appear. ![]() 1.8.9) then go to Tools > Manage Libraries… If you own a different board, rest assure that the sketches in this tutorial will still work as long as the correct wiring is followed.įirst, we need the ADX元45 Arduino library. This tutorial will focus on the ADX元45 breakout board as shown: The acceleration forces can be static (due to gravity only) or dynamic (due to motion and gravity).Ī more in-depth look at the ADX元45 is accessible via its datasheet: The ADX元45 can measure acceleration in as much as ☒g with an option to change the maximum to ±4g, ☘g and ☑6g. Hence, the ADX元45 gives acceleration forces in g units, g being the acceleration due to gravity equal to 9.8 m/s 2. If an object is at rest, only the force of gravity is acting on it. In reality, the ADX元45 is capable of measuring acceleration forces in the x, y and z axes.Īcceleration force is the force that causes an object to move.
0 Comments
Leave a Reply. |