Herunterladen Inhalt Inhalt Diese Seite drucken

Code Erklärung - SunFounder Da Vinci Kit Bedienungsanleitung

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

SunFounder Da Vinci Kit
pinMode(dhtPin, OUTPUT);
digitalWrite(dhtPin, LOW);
delay(18);
// then pull it up for 40 microseconds
digitalWrite(dhtPin, HIGH);
delayMicroseconds(40);
// prepare to read the pin
pinMode(dhtPin, INPUT);
// detect change and read data
for
( i=0;
i<
maxTim; i++) {
counter
=
0;
while
(digitalRead(dhtPin)
counter++;
delayMicroseconds(1);
if
(counter
break;
}
}
laststate
=
if
(counter
// ignore first 3 transitions
if
((i
>=
4)
// shove each bit into the storage bytes
dht11_dat[j/8]
if
(counter
dht11_dat[j/8]
j++;
}
}
// check we read 40 bits (8bit x 5 ) + verify checksum in the last byte
// print it out if data is good
if
((j
>=
40)
&&
(dht11_dat[4]
dat[3])
&
0xFF)) ) {
Fah
=
dht11_dat[2]
printf("Humidity = %d.%d %% Temperature = %d.%d * C (%.1f *
dht11_dat[0], dht11_dat[1], dht11_dat[2], dht11_dat[3], Fah);
}
}
int
main
(void) {
if(wiringPiSetup()
printf("setup wiringPi failed
return
1;
}
while
(1) {
readDht11();
delay(500);
}
return
0
;
}
Code Erklärung
232
==
laststate) {
==
255) {
digitalRead(dhtPin);
==
255) break;
&&
(i%2
==
0)) {
<<=
1;
>
50)
|=
1;
==
((dht11_dat[0]
9.
/
5.
+
*
==
-1){
//when initialize wiring failed, print messageto screen
!");
// wait 1sec to refresh
+
dht11_dat[1]
32;
(Fortsetzung der vorherigen Seite)
+
dht11_dat[2]
+
dht11_
F)\n",
Kapitel 1. Über das Da Vinci Kit

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis