1 wire communication problem

I removed those two lines, I got 20bits instead of 19 previously.
Still it does not work.
I'm thinking if that is the problem of pulseIn function.
Thanks.

johnwasser:

seanfan84:
But in the first code, I tried to read all bits into an array first.
If this is still not fast enough, I could not figure out a faster way.

If the first code you posted above is what you are calling 'the first code' you should read it again:

You signal for the DHT11 to start sending:

  digitalWrite(12,LOW);

delay(18);
  digitalWrite(12,HIGH);




Switch to input mode:


pinMode(12,INPUT);




Measure the length of the acknowledgement pulse:


response = pulseIn(12,HIGH);




AND PRINT OUT THE LENGTH OF THE ACKNOWLEDGEMENT PULSE:


Serial.println(response);
  Serial.println();




Before you fill the buffer with 40 more pulse lengths:


for (int i=0; i<40;i++){
     data[i] = pulseIn(12,HIGH);
  }