Advertisement
robathome

Untitled

Apr 6th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import time
  2. import board
  3. import busio
  4. import adafruit_l3gd20
  5.  
  6. # Hardware I2C setup:
  7. SerialObj = busio.I2C(board.SCL, board.SDA)
  8.  
  9. # When creating the L3GD20 instance, the second argument defines the range
  10. GyroSensor = adafruit_l3gd20.L3GD20_I2C(SerialObj, 2)
  11.  
  12. # Configure CTRLHz output data rate
  13. # - 800
  14. # Low-pass filter disabled
  15. GyroSensor.write_register(0x20, 0x5f)
  16.  
  17. # Configure CTRL2 register
  18. # - High-pass filter module disabled
  19. GyroSensor.write_register(0x21, 0x00)
  20.  
  21. # CTRL4 is already configured with
  22. # the L3GD20 instance!
  23. GyroSensor.write_register(0x23, 0x32)
  24.  
  25. # Begin sensor loop
  26. try:
  27.  
  28. StartTime = time.monotonic()
  29. while True:
  30.  
  31. LoopTime = time.monotonic()
  32. TimeStamp = LoopTime - StartTime
  33. GyroData = GyroSensor.gyro()
  34. 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