Files
pycom-documentation/4.-tutorials-and-examples/pysense.md
2018-08-01 16:17:37 +00:00

704 B

4.7 Pysense Examples

Accelerometer

This basic example shows how to read pitch and roll from the on-board accelerometer and output it in comma separated value (CSV) format over serial.

from LIS2HH12 import LIS2HH12
from pytrack import Pytrack
py = Pytrack()
acc = LIS2HH12()

while True:
   pitch = acc.pitch()
   roll = acc.roll()
   print('{},{}'.format(pitch, roll))
   time.sleep_ms(100)

If you want to visualise the data output by this script a Processing sketch is available here that will show the board orientation in 3D.