Herunterladen Inhalt Inhalt Diese Seite drucken

SunFounder Da Vinci Kit Bedienungsanleitung Seite 123

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

import
RPi.GPIO
as
import
time
dhtPin
=
17
GPIO.setmode(GPIO.BCM)
MAX_UNCHANGE_COUNT
STATE_INIT_PULL_DOWN
STATE_INIT_PULL_UP
STATE_DATA_FIRST_PULL_DOWN
STATE_DATA_PULL_UP
STATE_DATA_PULL_DOWN
def
readDht11():
GPIO.setup(dhtPin, GPIO.OUT)
GPIO.output(dhtPin, GPIO.HIGH)
time.sleep(0.05)
GPIO.output(dhtPin, GPIO.LOW)
time.sleep(0.02)
GPIO.setup(dhtPin, GPIO.IN, GPIO.PUD_UP)
unchanged_count
last
=
-1
data
=
[]
while
True:
current
=
GPIO.input(dhtPin)
data.append(current)
if
last
!=
unchanged_count
last
=
else:
unchanged_count
if
unchanged_count
break
state
=
STATE_INIT_PULL_DOWN
lengths
=
[]
current_length
for
current
in
current_length
if
state
==
if
current
state
else:
continue
if
state
==
if
current
state
else:
continue
if
state
==
if
current
1.7. 1 Ausgabe
GPIO
=
100
=
1
=
2
=
3
=
4
=
5
=
0
current:
=
0
current
+=
1
>
MAX_UNCHANGE_COUNT:
=
0
data:
+=
1
STATE_INIT_PULL_DOWN:
==
GPIO.LOW:
=
STATE_INIT_PULL_UP
STATE_INIT_PULL_UP:
==
GPIO.HIGH:
=
STATE_DATA_FIRST_PULL_DOWN
STATE_DATA_FIRST_PULL_DOWN:
==
GPIO.LOW:
SunFounder Da Vinci Kit
(Fortsetzung auf der nächsten Seite)
119

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis