DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
tOneTime VAR WORD ' Create variable to store result
tTwoTime var word
tThreeTime var word
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
Pause 500 ' Wait .5 second
input portd.2
input portd.3
input portd.4
input portd.5
input portd.6
main:
ADCIN 0, tOneTime
ADCIN 1, tTwoTime
ADCIN 2, tThreeTime
adcin 3, tOneTwo
adcin 4, tTwoThree
adcin 5, tThreeOne
if tOneTime < 50 then
tOneTime = 50
endif
if tTwoTime < 50 then
tTwoTime = 50
endif
if tThreeTime < 50 then
tThreeTime = 50
endif
if portd.2 = 1 then
high portb.4
gosub allOrAlt
else
low portd.1
low porte.2
low portc.3
low portb.4
low portb.5
low portb.6
low portb.7
endif
goto main
allOrAlt:
if portd.3 = 1 then
gosub all
endif
if portd.3 = 0 then
gosub alt
endif
return
all:
if portd.4 = 1 then
high portc.3
high portb.5
endif
if portd.4 = 0 then
low portc.3
low portb.5
endif
if portd.5 = 1 then
high porte.2
high portb.6
endif
if portd.5 = 0 then
low porte.2
low portb.6
endif
if portd.6 = 1 then
high portd.1
high portb.7
endif
if portd.6 = 0 then
low portd.1
low portb.7
endif
return
alt:
if portd.4 = 1 then
gosub oneOn
endif
if portd.4 = 0 then
gosub oneOff
endif
return
oneOn:
if portd.5 = 1 then
gosub oneOnTwoOn
endif
if portd.5 = 0 then
gosub oneOnTwoOff
endif
return
oneOff:
if portd.5 = 1 then
gosub oneOffTwoOn
endif
if portd.5 = 0 then
gosub oneOffTwoOff
endif
return
oneOnTwoOn:
if portd.6 = 1 then
gosub oneOnTwoOnThreeOn
endif
if portd.6 = 0 then
gosub oneOnTwoOnThreeOff
endif
return
oneOnTwoOff:
if portd.6 = 1 then
gosub oneOnTwoOffThreeOn
endif
if portd.6 = 0 then
gosub oneOnTwoOffThreeOff
endif
return
oneOffTwoOn:
if portd.6 = 1 then
gosub oneOffTwoOnThreeOn
endif
if portd.6 = 0 then
gosub oneOffTwoOnThreeOff
endif
return
oneOffTwoOff:
if portd.6 = 1 then
gosub oneOffTwoOffThreeOn
endif
if portd.6 = 0 then
gosub oneOffTwoOffThreeOff
endif
return
oneOnTwoOnThreeOn:
high portc.3
high portb.5
low porte.2
low portb.6
low portd.1
low portb.7
pause tOneTime
low portc.3
low portb.5
high porte.2
high portb.6
low portd.1
low portb.7
pause tTwoTime
low portc.3
low portb.5
low porte.2
low portb.6
high portd.1
high portb.7
pause tThreeTime
return
oneOnTwoOnThreeOff:
high portc.3
high portb.5
low porte.2
low portb.6
low portd.1
low portb.7
pause tOneTime
low portc.3
low portb.5
high porte.2
high portb.6
low portd.1
low portb.7
pause tTwoTime
return
oneOnTwoOffThreeOn:
high portc.3
high portb.5
low porte.2
low portb.6
low portd.1
low portb.7
pause tOneTime
low portc.3
low portb.5
low porte.2
low portb.6
high portd.1
high portb.7
pause tThreeTime
return
oneOffTwoOnThreeOn:
low portc.3
low portb.5
high porte.2
high portb.6
low portd.1
low portb.7
pause tTwoTime
low portc.3
low portb.5
low porte.2
low portb.6
high portd.1
high portb.7
pause tThreeTime
return
oneOnTwoOffThreeOff:
high portc.3
high portb.5
low porte.2
low portb.6
low portd.1
low portb.7
return
oneOffTwoOnThreeOff:
low portc.3
low portb.5
high porte.2
high portb.6
low portd.1
low portb.7
return
oneOffTwoOffThreeOn:
low portc.3
low portb.5
low porte.2
low portb.6
high portd.1
high portb.7
return
oneOffTwoOffThreeOff:
low portc.3
low portb.5
low porte.2
low portb.6
low portd.1
low portb.7
return