Skip to content

Commit 786e991

Browse files
committed
added a combined python example for the lsm303dlh
1 parent 7f66ca2 commit 786e991

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

LSM303/lsm303dlh_combined.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from time import sleep
2+
import board
3+
import busio
4+
import adafruit_lsm303_accel
5+
import adafruit_lsm303dlh_mag
6+
7+
i2c = busio.I2C(board.SCL, board.SDA)
8+
mag = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
9+
accel = adafruit_lsm303_accel.LSM303_Accel(i2c)
10+
11+
while True:
12+
print("Acceleration (m/s^2): X=%0.3f Y=%0.3f Z=%0.3f"%accel.acceleration)
13+
print("Magnetometer (micro-Teslas)): X=%0.3f Y=%0.3f Z=%0.3f"%mag.magnetic)
14+
print("")
15+
sleep(0.5)
16+

0 commit comments

Comments
 (0)