Sub Main() dim seconds as single Const crlf as String = Chr(&H0d) Const qsize as Byte = 50 Dim oq(1 to qsize) as Byte Dim iq(1 to qsize) as byte Dim Channel1 as boolean = false Dim Channel2 as boolean = false Dim Channel3 as boolean = false call putpin(28,0) call putpin(25,0) call putpin(27,1) call putpin(26,1) const HHigh as single = 8.4491E-04 const LHigh as single = 6.5491E-04 const Hlow as single = 4.369125E-04 const LLow as single = 2.869125E-04 dim checked as boolean = false dim lowcount as byte dim check as byte dim counter as byte dim width(135) as single call putpin(25,1) call putpin(24,1) call putpin(23,1) call delay(1.5) Call OpenQueue(iq, SizeOf(iq)) Call OpenQueue(oq, SizeOf(oq)) call definecom(3, 5, 4, &H08) Call Opencom(3,4800, iq, oq) call putpin(27,0) call putpin(26,0) call putpin(25,0) call putpin(24,0) call putpin(23,0) call putpin(14,0) call putpin(19,0) Start: counter = 1 do until counter = 132 call pulsein(28,1,width(counter)) counter= counter+1 loop check = 1 counter = 0 lowcount = 0 mid: counter = counter + 1 'find header do seconds = CSng(Register.RTCTick) / CSng(Register.RTCTickFrequency) if width(counter)>Llow and width(counter)Llow and width(counter+1)Llow and width(counter+2)Llow and width(counter+3)Llow and width(counter+4)Llow and width(counter+5)Llow and width(counter+6)Llow and width(counter+7)Llow and width(counter+8)Llow and width(counter+9)Llow and width(counter+10)Llow and width(counter+11)Llow and width(counter+12) llow and width(counter+27) < Hlow and width(counter+46)> llow and width(counter+46) < Hlow and width(counter+47)> llow and width(counter+47) < Hlow and width(counter+49)> llow and width(counter+49) < Hlow and width(counter+51)> llow and width(counter+51) < Hlow and width(counter+48) >LHigh and width(counter+48) < HHigh and width(counter+50) >LHigh and width(counter+50) < HHigh then checked = false Call PutQueueStr(oq, "RRrr" & crlf) call putpin (25,1) call putpin (27,1) channel1 = true call delay(0.05) Call PutQueueStr(oq, "1" & crlf) end if end if if checked = true then if width(counter+27)> llow and width(counter+27) < Hlow and width(counter+46)> llow and width(counter+46) < Hlow and width(counter+47)> llow and width(counter+47) < Hlow and width(counter+48)> llow and width(counter+48) < Hlow and width(counter+51)> llow and width(counter+51) < Hlow and width(counter+52)> llow and width(counter+52) < Hlow and width(counter+49) >LHigh and width(counter+49) < HHigh and width(counter+50) >LHigh and width(counter+50) < HHigh then checked = false Call PutQueueStr(oq, "RRrr" & crlf) call putpin (19,1) call putpin (24,1) channel2 = true call delay(0.05) Call PutQueueStr(oq, "2" & crlf) end if end if if checked = true then if width(counter+27)> llow and width(counter+27) < Hlow and width(counter+46)> llow and width(counter+46) < Hlow and width(counter+47)> lhigh and width(counter+47) < Hhigh and width(counter+48)> llow and width(counter+48) < Hlow and width(counter+51)> lhigh and width(counter+51) < Hhigh and width(counter+52)> llow and width(counter+52) < Hlow and width(counter+49) >LHigh and width(counter+49) < HHigh and width(counter+50) >LLow and width(counter+50) < HLow then checked = false Call PutQueueStr(oq, "RRrr" & crlf) call putpin (23,1) call putpin (14,1) channel3 = true call delay(0.05) Call PutQueueStr(oq, "3" & crlf) end if end if if counter = 132 then goto start end if goto mid checked = false loop goto start End Sub