dim cntchg as word
dim zone1 as word
dim zone2 as word
dim zone3 as word
get3d:
config portb = output
portb = 0 ' all low
'set to input
config portb.4 = input
'get how long it takes to chrg cap
for cntchg = 0 to 10000
if portb.4 = 1 then
zone1 = cntchg
goto zone2
endif
cntchg = cntchg + 1
next cntchg
'did not happen in time
zone1 = 0
zone2:
cntchrg = 0
'set to input
config portb.5 = input
'get how long it takes to chrg cap
for cntchg = 0 to 10000
if portb.5 = 1 then
zone2 = cntchrg
goto zone3
endif
next cntchrg
'did not happen in time
zone2 = 0
zone3:
cntchrg = 0
'set to input
config portb.6 = input
'get how long it takes to chrg cap
for cntchg = 0 to 10000
if portb.5 = 1 then
zone3 = cntchrg
goto send3d
endif
next cntchrg
'did not happen in time
zone3 = 0
send3d:
'used with usb2serial cable - saves on max232.
seroutinv portb.2, 4800, "x", zone1, "y", zone2, "z", "zone3"
waitms 20
goto get3d
end