/ examples / lsm303dlh_mag_fast.py
lsm303dlh_mag_fast.py
 1  """ Read data from the magnetometer and print it out, ASAP! """
 2  
 3  import board
 4  import busio
 5  import adafruit_lsm303dlh_mag
 6  
 7  i2c = busio.I2C(board.SCL, board.SDA)
 8  sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
 9  
10  while True:
11      mag_x, mag_y, mag_z = sensor.magnetic
12      print("{0:10.3f} {1:10.3f} {2:10.3f}".format(mag_x, mag_y, mag_z))