Left it too long to edit the above post.. but here's my understanding - Please correct me if I'm wrong
Code:
read_dht:
TRISA.1 = 0 'make pin input
high dht_data : pause 250 'take pin high for 250ms
low dht_data : pause 20 'take pin low for 20ms
high dht_data : pauseus 40 'send 40us pulse
PulsIn PORTA.1, 1, dht 'measure incomming high pulse and store in variable dht
if dht < 9 then goto badresponse 'if pulse width is less than 9 got bad responce. 10mhz xtal should give 4us resolution
for x = 31 to 0 step -1 'loop to read pulse widths from bits 31 - 0
PulsIn PORTA.1, 1, dht[x] ' 1 'measure incoming pulse width and add it to the array variable
next x 'go round the loop until 32 bits have been read
hum=0 'clear variable
j = 15
for x = 31 to 16 step - 1 'loop round the last 16 bits
if dht(x)>=35 then hum.0[j] = 1 'if any value of dht(31 to 16) is equal or over 35 then ?????
j = j-1 'J is reduced by 1
next x 'go round until x = 16
return
badresponse:
LCDOut $FE,$80+9,"RH N/C"
return
I'm stuck on the IF THEN section of the last for next loop
Bookmarks