IR.INIT 21,12
pin.mode 5, input
pin.mode 4, input
pin.mode 2, input
pin.mode 22, input
TFT.INIT 0
TFT.FILL TFT.COLOR(black)
ONINFRARED irReceived
interrupt 5, detectado1
interrupt 4, detectado2
interrupt 2, detectado3
interrupt 22, detectado4
movimento1 = 0
movimento2 = 0
movimento3 = 0
movimento4 = 0
ativado1 = 1
ativado2 = 1
ativado3 = 1
ativado4 = 1
while 1
if ativado1 then
if movimento1 = 0 then
TFT.RECT 0,0,110,150,TFT.COLOR(green),1
else
TFT.RECT 0,0,110,150,TFT.COLOR(red),1
end if
else
TFT.RECT 0,0,110,150,TFT.COLOR(orange),1
end if
if ativado2 then
if movimento2 = 0 then
TFT.RECT 110,0,110,150,TFT.COLOR(green),1
else
TFT.RECT 110,0,110,150,TFT.COLOR(red),1
end if
else
TFT.RECT 110,0,110,150,TFT.COLOR(orange),1
end if
if ativado3 then
if movimento3 = 0 then
TFT.RECT 0,150,110,150,TFT.COLOR(green),1
else
TFT.RECT 0,150,110,150,TFT.COLOR(red),1
end if
else
TFT.RECT 0,150,110,150,TFT.COLOR(orange),1
end if
if ativado4 then
if movimento4 = 0 then
TFT.RECT 110,150,110,150,TFT.COLOR(green),1
else
TFT.RECT 110,150,110,150,TFT.COLOR(red),1
end if
else
TFT.RECT 110,150,110,150,TFT.COLOR(orange),1
end if
PAUSE 50
wend
irReceived:
PRINT "Recebeu: "; IR.GET$
if IR.GET$ = "FF0CF3" then
if ativado1 = 0 then
PRINT "Setor 1: ativado"
ativado1 = 1
else
PRINT "Setor 1: desativado"
ativado1 = 0
end if
end if
if IR.GET$ = "FF18E7" then
if ativado2 = 0 then
PRINT "Setor 2: ativado"
ativado2 = 1
else
PRINT "Setor 2: desativado"
ativado2 = 0
end if
end if
if IR.GET$ = "FF5EA1" then
if ativado3 = 0 then
PRINT "Setor 3: ativado"
ativado3 = 1
else
PRINT "Setor 3: desativado"
ativado3 = 0
end if
end if
if IR.GET$ = "FF08F7" then
if ativado4 = 0 then
PRINT "Setor 4: ativado"
ativado4 = 1
else
PRINT "Setor 4: desativado"
ativado4 = 0
end if
end if
RETURN
detectado1:
if pin(5) = 0 then
print "Setor 1: 0"
movimento1 = 0
else
print "Setor 1: 1"
movimento1 = 1
end if
return
detectado2:
if pin(4) = 0 then
print "Setor 2: 0"
movimento2 = 0
else
print "Setor 2: 1"
movimento2 = 1
end if
return
detectado3:
if pin(2) = 0 then
print "Setor 3: 0"
movimento3 = 0
else
print "Setor 3: 1"
movimento3 = 1
end if
return
detectado4:
if pin(22) = 0 then
print "Setor 4: 0"
movimento4 = 0
else
print "Setor 4: 1"
movimento4 = 1
end if
return
end