Herunterladen Inhalt Inhalt Diese Seite drucken

SunFounder Da Vinci Kit Bedienungsanleitung Seite 321

Für den raspberry pi 4 modell b, 3 modell a +, 3 modell b +, 3 modell b, 2 modell b, 1 modell b +, 1 modell a +, zero w and zero
Inhaltsverzeichnis

Werbung

dist(a,b):
def
return
math.sqrt((a
get_y_rotation(x,y,z):
def
radians
=
math.atan2(x, dist(y,z))
return
-math.degrees(radians)
def
get_x_rotation(x,y,z):
radians
=
math.atan2(y, dist(x,z))
math.degrees(radians)
return
def
mpu6050():
accel_xout
=
read_word_2c(0x3b)
accel_yout
=
read_word_2c(0x3d)
accel_zout
=
read_word_2c(0x3f)
accel_xout_scaled
accel_yout_scaled
accel_zout_scaled
angle=get_y_rotation(accel_xout_scaled, accel_yout_scaled, accel_zout_scaled)
return
angle
#Stepper Motor
def
rotary(direction):
if(direction
==
for
j
in
range(4):
for
i
in
GPIO.output(motorPin[i],0x99>>j
time.sleep(stepSpeed)
elif(direction
for
j
in
range(4):
for
i
in
GPIO.output(motorPin[i],0x99<<j
time.sleep(stepSpeed)
def
setup():
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
for
i
in
motorPin:
GPIO.setup(i, GPIO.OUT)
def
loop():
while
True:
angle=mpu6050()
if
angle
>=45
rotary('a')
elif
angle <=-45:
rotary('c')
def
destroy():
GPIO.cleanup()
if
__name__
==
'__main__':
setup()
try:
1.9. 3 Erweiterung
a)+(b
b))
*
*
=
accel_xout
/
16384.0
=
accel_yout
/
16384.0
=
accel_zout
/
16384.0
'c'):
range(4):
==
'a'):
range(4):
:
SunFounder Da Vinci Kit
(Fortsetzung der vorherigen Seite)
&
(0x08>>i))
&
(0x80>>i))
(Fortsetzung auf der nächsten Seite)
317

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis