Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jackw01/l3gd20-python
Python library for the L3GD20 I2C 3-axis gyroscope
https://github.com/jackw01/l3gd20-python
Last synced: about 5 hours ago
JSON representation
Python library for the L3GD20 I2C 3-axis gyroscope
- Host: GitHub
- URL: https://github.com/jackw01/l3gd20-python
- Owner: jackw01
- License: mit
- Created: 2020-09-07T20:56:48.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-09T21:54:36.000Z (about 4 years ago)
- Last Synced: 2024-10-14T09:40:20.797Z (25 days ago)
- Language: Python
- Size: 4.88 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# l3gd20-python
Python library for the L3GD20 I2C 3-axis gyroscope## Usage
1. Install the Python `smbus` module for your platform (`sudo apt install python-smbus` for Debian or Ubuntu Linux)
2. `pip install l3gd20-python`
3. `sudo l3gd20_test`## Example Code
```python
import time
import smbus
import l3gd20i2c_channel = 1
bus = smbus.SMBus(i2c_channel)# Will raise OSError if device is not connected
device = l3gd20.L3GD20(bus)# Set range, 250 degrees/second is default
# Supported:
# RANGE_250DPS
# RANGE_500DPS
# RANGE_2000DPS
device.set_range(l3gd20.RANGE_250DPS)# Wait for gyro to stabilize
time.sleep(0.5)while True:
# Returns x,y,z tuple with values in degrees/second
data = device.read()
print([round(v, 2) for v in data])
time.sleep(0.1)
```