Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import board
- import busio
- import adafruit_l3gd20
- # Hardware I2C setup:
- SerialObj = busio.I2C(board.SCL, board.SDA)
- # When creating the L3GD20 instance, the second argument defines the range
- GyroSensor = adafruit_l3gd20.L3GD20_I2C(SerialObj, 2)
- # Configure CTRLHz output data rate
- # - 800
- # Low-pass filter disabled
- GyroSensor.write_register(0x20, 0x5f)
- # Configure CTRL2 register
- # - High-pass filter module disabled
- GyroSensor.write_register(0x21, 0x00)
- # CTRL4 is already configured with
- # the L3GD20 instance!
- GyroSensor.write_register(0x23, 0x32)
- # Begin sensor loop
- try:
- StartTime = time.monotonic()
- while True:
- LoopTime = time.monotonic()
- TimeStamp = LoopTime - StartTime
- GyroData = GyroSensor.gyro()
- print('{0:0.6f},{1:0.5f},{2:0.5f},{2:0.5f}'.format(TimeStamp, GyroData[1],GyroData[2], GyroData[3]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement