Herunterladen Inhalt Inhalt Diese Seite drucken

SunFounder Da Vinci Kit Bedienungsanleitung Seite 307

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

MotorPin2
=
6
MotorEnable
=
13
BtnPin
=
22
def
setup():
p_M1,p_M2
global
ADC0834.setup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(MotorPin1, GPIO.OUT)
GPIO.setup(MotorPin2, GPIO.OUT)
p_M1=GPIO.PWM(MotorPin1,2000)
p_M2=GPIO.PWM(MotorPin2,2000)
p_M1.start(0)
p_M2.start(0)
GPIO.setup(MotorEnable, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(BtnPin, GPIO.IN)
def
temperature():
analogVal
=
ADC0834.getResult()
Vr
=
5
float(analogVal)
*
Rt
=
10000
Vr
*
temp
=
1/(((math.log(Rt
Cel
=
temp
-
273.15
Fah
=
Cel
1.8
*
return
Cel
def
motor(level):
if
level
==
0:
GPIO.output(MotorEnable, GPIO.LOW)
return
0
if
level>=4:
level
=
4
GPIO.output(MotorEnable, GPIO.HIGH)
p_M1.ChangeDutyCycle(level
return
level
def
main():
lastState=0
level=0
markTemp
=
temperature()
while
True:
currentState =GPIO.input(BtnPin)
currentTemp=temperature()
if
currentState
level=(level+1)%5
markTemp
time.sleep(0.5)
lastState=currentState
if
level!=0:
if
currentTemp-markTemp
level
markTemp=currentTemp
if
currentTemp-markTemp
level
markTemp=currentTemp
1.9. 3 Erweiterung
/
255
/
(5
-
Vr)
/
10000))
/
+
32
25)
*
==
1
and
lastState
=
currentTemp
<=
=
level
-1
>=
=
level
+1
3950)
+
(1
/
(273.15+25)))
==
0:
-2:
2:
SunFounder Da Vinci Kit
(Fortsetzung der vorherigen Seite)
(Fortsetzung auf der nächsten Seite)
303

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis