Thanks Tabsoft,
I'll give that a try. I did stumble across a similar thread (http://www.picbasic.co.uk/forum/showthread.php?t=17867) and amended the code to
with an amended display line, but get random digits all over the range from 6453% to 17% !!Code:read_dht: TRISA.1 = 0 ' high dht_data low dht_data : pause 18' send 18ms low high dht_data : pauseus 30 ' send 30us hi TRISA.1 = 0 PulsIn PORTA.1, 1, dht if dht < 9 then goto badresponse for x = 0 to 31 PulsIn PORTA.1, 1, dht(x) ' 1 next x For x = 0 to 31 if dht(x)>=9 and dht(x)<=21 then dht(x)=0 'if pulsewidth between 20 and 40uS then read as '0' if dht(x)>=29 and dht(x)<=41 then dht(x)=1 'if pulsewidth between 60 and 80uS then read as '1' next x hum=32768*dht(1)+16384*dht(2)+8192*dht(3)+4096*dht(4)+2048*dht(5)+1024*dht(6)+512*dht(7)+256*dht(8)+128*dht(9)+64*dht(10)+32*dht(11)+16*dht(12)+8*dht(13)+4*dht(14)+2*dht(15)+1*dht(16) return
I'll give your example a try a and will get back




Bookmarks