Ist zwar ein sehr individuelles Projekt, trotzdem sei Schaltplan, Code und Layout nicht vorenthalten...
(es wird nur der Kanal für die Y-Achse ausgelesen)
Code:
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
31
32
33
34
35
36
37
38
39
40
#picaxe 08m2
setfreq m8 'setzt Systemfrequenz auf 8MHz
symbol ya = w0
symbol ya.lsb = b0
symbol ya.msb = b1
symbol Grad = w2
symbol Level = w10
dacsetup %10100000
hi2csetup i2cmaster, $D0, i2cfast_8, i2cbyte 'I2C initialisieren
pause 1000
hi2cout $6B, (%00000001) 'MPU-6050 wecken
pause 100
MAIN:
hi2cin $3D, (ya.msb, ya.lsb) '$43 is gyro X-axis first register
'$45 is gyro Y-axis first register
'$47 is gyro Z-axis first register
'$3B is accel X-axis first register
'$3D is accel Y-axis first register
'$3F is accel Z-axis first register
ya = ya + 16384 min 8192 max 24576 'Nullunktverschiebung
'Bereich limitieren auf 90 +/- 45 Grad
Grad = ya / 182
Level = ya - 8192 / 512 max 31 'DACLevel berechnen
daclevel Level
pause 100
goto MAIN


------------------------------------------------
Danke und Gruß
Joe