17-10-2015, 03:05 PM
code for interfacing pir sensor with 8051 mcu
org 00h
mov p1,#0ffh
mov p2,#00h
mov a,p1
jnz check
;jz loop
loop:
mov a,p1
jnz check
jz loop
check:
acall delay
mov a,p1
jnz check1
jz loop
check1:
mov p2,#0ffh
acall dlay1
mov p2,#00h
sjmp loop
delay:
mov r4,#255d
loop3:
mov r1,#255d
loop2:
mov r3,#255d
loop1:
djnz r3,loop1
djnz r1,loop2
djnz r4,loop3
ret
dlay1:
mov r4,#10d
lop3:
mov r1,#255d
lop2:
mov r3,#255d
lop1:
djnz r3,loop1
djnz r1,loop2
djnz r4,loop3
ret
end
org 00h
mov p1,#0ffh
mov p2,#00h
mov a,p1
jnz check
;jz loop
loop:
mov a,p1
jnz check
jz loop
check:
acall delay
mov a,p1
jnz check1
jz loop
check1:
mov p2,#0ffh
acall dlay1
mov p2,#00h
sjmp loop
delay:
mov r4,#255d
loop3:
mov r1,#255d
loop2:
mov r3,#255d
loop1:
djnz r3,loop1
djnz r1,loop2
djnz r4,loop3
ret
dlay1:
mov r4,#10d
lop3:
mov r1,#255d
lop2:
mov r3,#255d
lop1:
djnz r3,loop1
djnz r1,loop2
djnz r4,loop3
ret
end