Debian Codegraph @

examples/atmega32/accelerometer_robot.py

raw symbols SCIP
1 # Control a robotic arm via PCA9685 PWM, with an MPU6050 accelerometer as user input.
2 # MPU6050 Ax range: Servo1 range, Ax Range to Servo2 Range, Ay range to Servo3 range for slope, intercept calculations
3 # 9700 - 16700 : 64 - 138 , 9700 -> 16700 : 131 - 33 -10K -> 10K : 20 - 160
4
5 #from kuttyPy import *
6 PCA9685_init()
7 MPU6050_init()
8 MPU6050_kalman_set(1)
9
10 m1 = (138-64.)/(16700-9700)
11 c1 = 64. - 9700*m1
12 m2 = (33-131.)/(16700-9700)
13 c2 = 131. - 9700*m2
14 m3 = (160-20.)/(10000. + 10000)
15 c3 = 20. + 10000*m3
16
17 while(1):
18 x = MPU6050_all()
19 if x is not None:
20 PCA9685_set(1, int(m1*x[0]+c1))
21 PCA9685_set(2, int(m2*x[0]+c2))
22 PCA9685_set(3, int(m3*x[1]+c3))