Skip to content

Adding ADXL345 init to all examples. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions examples/adxl34x_freefall_detection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@

i2c = busio.I2C(board.SCL, board.SDA)

accelerometer = adafruit_adxl34x.ADXL345(i2c)
# For ADXL343
accelerometer = adafruit_adxl34x.ADXL343(i2c)
# For ADXL345
# accelerometer = adafruit_adxl34x.ADXL345(i2c)

accelerometer.enable_freefall_detection()
# alternatively you can specify attributes when you enable freefall detection for more control:
# accelerometer.enable_freefall_detection(threshold=10,time=25)

while True:
print("%f %f %f"%accelerometer.acceleration)
print("%f %f %f" % accelerometer.acceleration)

print("Dropped: %s"%accelerometer.events["freefall"])
print("Dropped: %s" % accelerometer.events["freefall"])
time.sleep(0.5)
11 changes: 8 additions & 3 deletions examples/adxl34x_motion_detection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@

i2c = busio.I2C(board.SCL, board.SDA)

accelerometer = adafruit_adxl34x.ADXL345(i2c)
# For ADXL343
accelerometer = adafruit_adxl34x.ADXL343(i2c)
# For ADXL345
# accelerometer = adafruit_adxl34x.ADXL345(i2c)

accelerometer.enable_motion_detection()
# alternatively you can specify the threshold when you enable motion detection for more control:
# accelerometer.enable_motion_detection(threshold=10)

while True:
print("%f %f %f"%accelerometer.acceleration)
print("%f %f %f" % accelerometer.acceleration)

print("Motion detected: %s"%accelerometer.events['motion'])
print("Motion detected: %s" % accelerometer.events['motion'])
time.sleep(0.5)
11 changes: 8 additions & 3 deletions examples/adxl34x_tap_detection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@

i2c = busio.I2C(board.SCL, board.SDA)

accelerometer = adafruit_adxl34x.ADXL345(i2c)
# For ADXL343
accelerometer = adafruit_adxl34x.ADXL343(i2c)
# For ADXL345
# accelerometer = adafruit_adxl34x.ADXL345(i2c)

accelerometer.enable_tap_detection()
# you can also configure the tap detection parameters when you enable tap detection:
# accelerometer.enable_tap_detection(tap_count=2,threshold=20, duration=50)

while True:
print("%f %f %f"%accelerometer.acceleration)
print("%f %f %f" % accelerometer.acceleration)

print("Tapped: %s"%accelerometer.events['tap'])
print("Tapped: %s" % accelerometer.events['tap'])
time.sleep(0.5)