mirror of
https://github.com/sascha-hemi/pycom-documentation.git
synced 2026-03-21 13:06:14 +01:00
24 lines
710 B
Markdown
24 lines
710 B
Markdown
# 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.
|
|
|
|
```python
|
|
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](https://github.com/pycom/pycom-libraries/tree/master/examples/pytrack_pysense_accelerometer) that will show the board orientation in 3D.
|
|
|