-
-
Save tkeyo/240540f796590adc005ab75b946d4952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import utime | |
from machine import Timer, Pin, I2C | |
from drivers.mpu6500 import MPU6500, SF_DEG_S, SF_M_S2 | |
# MPU6500 module was adjusted from: | |
# https://github.com/tuupola/micropython-mpu9250 | |
# set up I2C serial communication protcol | |
i2c = I2C(scl=Pin(22), sda=Pin(21)) | |
# create MPU6500 instance | |
mpu6500 = MPU6500(i2c, accel_sf=SF_M_S2, gyro_sf=SF_DEG_S) | |
# read sensor function | |
def read_sensor(timer): | |
print(utime.ticks_ms(), mpu6500.acceleration, mpu6500.gyro) | |
# hardware timer setup | |
timer = Timer(0) | |
timer.init(period=10, mode=Timer.PERIODIC, callback=read_sensor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment