예제 #1
0
        if xGyro > 32767:
            xGyro -= 65536

        yGyro = data[2] * 256 + data[3]
        if yGyro > 32767:
            yGyro -= 65536

        zGyro = data[4] * 256 + data[5]
        if zGyro > 32767:
            zGyro -= 65536

        return {'x': xGyro, 'y': yGyro, 'z': zGyro}


from MPU6000 import MPU6000
mpu6000 = MPU6000()

while True:
    mpu6000.gyro_config()
    mpu6000.accl_config()
    mpu6000.power_management_1()
    time.sleep(0.1)
    accl = mpu6000.read_accl()
    print "Acceleration in X-Axis : %d" % (accl['x'])
    print "Acceleration in Y-Axis : %d" % (accl['y'])
    print "Acceleration in Z-Axis : %d" % (accl['z'])
    gyro = mpu6000.read_gyro()
    print "X-Axis of Rotation : %d" % (gyro['x'])
    print "Y-Axis of Rotation : %d" % (gyro['y'])
    print "Z-Axis of Rotation : %d" % (gyro['z'])
    print " ************************************ "