Sory što se tiče ponavljanja labela to je greška u kopiranju.Evo koda sa objašnjenjem
Code:
define osc 4
TRISB=%00000000
TRISA=%00011
pause 10000
pocetak:
high portb.5
if PortA.0=0 Then 'ulaz s prvog TSOP 1838
GoTo p
endif
If PortA.1=0 Then 'ulaz s drugog TSOP 1838
goto g
endif
goto pocetak
p:
If PortA.1=0 Then
high portb.4' pali led diodu
goto pocetak
endif
goto p
g:
if PortA.0=0 Then
low portb.4 'gasi led diodu
goto pocetak
endif
goto g
Da to je kod samo za probu TSOP-a da vidim kako rade.A kasnije ću ja sam da probam nešto da skombinujem.
Nešto poput ovoga
Code:
'PortB 0,1,2,3 ulazi sa TSOP-a
'PortB 4,5,6,7 pale led diode
DEFINE OSC 4
TRISB=%00001111
i var byte
Minute var byte
Second var byte
Ticks var byte
s var byte
clear
OPTION_REG = $55
INTCON = $A0
On Interrupt Goto TickInterrupt
i=10
OPTION_REG.7 = 1
pocetak:
If PortB.0=0 Then
goto paliodozgo
EndIf
If PortB.3=0 Then
Goto paliodozdol
Endif
If PortB.1=0 Then
Goto gasiodozgo
Endif
If PortB.2=0 Then
goto gasiodozdol
endif
If i<10 then
i=10
endif
if s=30 then
low PortB.4
low PortB.5
Low PortB.6
Low PortB.7
endif
second=0
goto pocetak
paliodozgo:
Pause 10
If Second = 10 Then
goto pocetak
endif
If PortB.1=0 Then gosub pali
goto paliodozgo
pali:
pause 10
i=i+1
If i>10 then
High PortB.4
low PortB.5
low PortB.6
Low PortB.7
s=0
Pause 100
endif
goto pocetak
paliodozdol:
Pause 10
If Second = 10 Then
goto pocetak
endif
If portB.2=0 Then gosub pali2
goto paliodozdol
pali2
pause 10
i=i+1
If i>10 then
High PortB.5
Low PortB.6
Low PortB.7
Low PortB.4
s=0
Pause 100
endif
goto pocetak
gasiodozgo:
Pause 10
If Second = 10 Then
goto pocetak
endif
If PortB.0=0 Then gosub gasi
goto gasiodozgo
gasi:
pause 10
i=i-1
if i=10 then
Low PortB.4
Low PortB.5
High PortB.6
low PortB.7
s=0
Pause 100
endif
goto pocetak
gasiodozdol:
Pause 10
If Second = 10 Then
goto pocetak
endif
If PortB.3=0 Then gosub gasi2
goto gasiodozdol
gasi2:
pause 10
i=i-1
If i=10 then
High PortB.7
Low PortB.4
Low PortB.5
Low PortB.6
s=0
Pause 100
endif
goto pocetak
disable
TickInterrupt:
Ticks = Ticks + 1
If Ticks < 61 Then ExitInterrupt
Ticks = 0
Second = Second + 1
s=s+1
If Second >= 60 Then
Second = 0
Minute = Minute + 1
If Minute >= 60 Then
Minute = 0
endif
Endif
ExitInterrupt:
INTCON.2 = 0
Resume
end
end
Možda treba još nešto doradit ali to je samo ideja za sada.