Skip to content

Commit 3aafd38

Browse files
author
ladyada
committed
add demo
1 parent e5ea17e commit 3aafd38

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/lsm6ds_pedometer.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
""" This example shows off how to use the step counter built
2+
into the ST LSM6DS series IMUs. The steps are calculated in
3+
the chip so you don't have to do any calculations!"""
4+
5+
import time
6+
import board
7+
import busio
8+
from adafruit_lsm6ds import LSM6DS33, Rate, AccelRange
9+
10+
i2c = busio.I2C(board.SCL, board.SDA)
11+
12+
sensor = LSM6DS33(i2c)
13+
14+
# enable accelerometer sensor @ 2G and 26 Hz
15+
sensor.accelerometer_range = AccelRange.RANGE_2G
16+
sensor.accelerometer_data_rate = Rate.RATE_26_HZ
17+
# no gyro used for step detection
18+
sensor.gyro_data_rate = Rate.RATE_SHUTDOWN
19+
20+
#enable the pedometer
21+
sensor.pedometer_enable(True)
22+
23+
while True:
24+
print("Steps: ", sensor.pedometer_steps)
25+
time.sleep(1)

0 commit comments

Comments
 (0)