forked from nickcoutsos/MPU-6050-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·30 lines (24 loc) · 739 Bytes
/
Copy pathexample.py
File metadata and controls
executable file
·30 lines (24 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python
"""
Released under the MIT License
Copyright 2015 MrTijn/Tijndagamer
"""
# Import the MPU6050 class from the MPU6050.py file
from MPU6050 import MPU6050
from time import sleep
# Create a new instance of the MPU6050 class
sensor = MPU6050(0x68)
while True:
accel_data = sensor.get_accel_data()
gyro_data = sensor.get_gyro_data()
temp = sensor.get_temp()
print("Accelerometer data")
print("x: " + str(accel_data['x']))
print("y: " + str(accel_data['y']))
print("z: " + str(accel_data['z']))
print("Gyroscope data")
print("x: " + str(gyro_data['x']))
print("y: " + str(gyro_data['y']))
print("z: " + str(gyro_data['z']))
print("Temp: " + str(temp) + " C")
sleep(0.5)