Instructions

IDUINO for maker’s life
www.openplatform.cc 79
}
void start_test () {
digitalWrite (DHpin, LOW); // bus down, send start signal
delay (30); // delay greater than 18ms, so DHT11 start signal can be
detected
digitalWrite (DHpin, HIGH);
delayMicroseconds (40); // Wait for DHT11 response
pinMode (DHpin, INPUT);
while (digitalRead (DHpin) == HIGH);
delayMicroseconds (80); // DHT11 response, pulled the bus 80us
if (digitalRead (DHpin) == LOW);
delayMicroseconds (80); // DHT11 80us after the bus pulled to start
sending data
for (int i = 0; i < 4; i ++) // receive temperature and humidity data,
the parity bit is not considered
dat[i] = read_data ();
pinMode (DHpin, OUTPUT);
digitalWrite (DHpin, HIGH); // send data once after releasing the bus,
wait for the host to open the next Start signal
}
void setup () {
Serial.begin (9600);
pinMode (DHpin, OUTPUT);
}
void loop () {
start_test ();
Serial.print ("Current humdity =");
Serial.print (dat [0], DEC); // display the humidity-bit integer;
Serial.print ('.');