Demo variasi nyala LED pada Port 1 File name DEMOLED.H51

; ---------------------------------------------------------
; Demo variasi nyala LED pada Port 1 File name DEMOLED.H51
; ---------------------------------------------------------
Org 0h
nop
Mulai: Mov R2,#7
Mov A,#11111110B ; Masukkan data 11111111B ke Accumulator
Ulang1: Mov P1,A ; keluarkan isi Accumulator ke Port 1
CLR C
RLC A ; panggil sub routine Delay
call Delay ; Rotate Accumulator left with carry
DJNZ R2,ULANG1 ; ÚÄ<Ä b7Äb6Äb5Äb4Äb3Äb2Äb1Äb0 <Ä CÄ¿ MOV R2,#7 ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄ>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
Ulang2: Mov P1,A ; keluarkan isi Accumulator ke Port 1
setb C
RRC A
call Delay
DJNZ R2,ULANG2
mov P1,#0FFh
call delay
call delay
call delay
LED_kanan_kiri:
clr P1.3
clr P1.4
call delay
clr P1.2
clr P1.5
call delay
clr P1.1
clr P1.6
call delay
clr P1.0
clr P1.7
call delay
call delay
call delay
setb P1.0
setb P1.7
call delay
setb P1.1
setb P1.6
call delay
setb P1.2
setb P1.5
call delay
setb P1.3
setb P1.4
call delay
call delay
mov R4,#2
LED_jalan_dua:
Mov R2,#6
Mov A,#11111100B ; Masukkan data 111111100B ke Accumulator
loop1: Mov P1,A ; keluarkan isi Accumulator ke Port 1
RL A ; panggil sub routine Delay
call Delay ; Rotate Accumulator left with carry
DJNZ R2,loop1 ; ÚÄ<Ä b7Äb6Äb5Äb4Äb3Äb2Äb1Äb0 <ÄÄ¿ MOV R2,#6 ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄ>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
loop2: Mov P1,A ; keluarkan isi Accumulator ke Port 1
RR A
call Delay
DJNZ R2,loop2
djnz R4,LED_jalan_dua
LED_jalan_satu_satu:
mov dptr,#LED_satu
mov R4,#36
next1: clr A
Movc A,@A+DPTR
cpl A
Mov P1,A
inc dptr
call Delay
djnz R4,next1
call delay
call delay
call delay
mov dptr,#LED_satu
mov R4,#36
next2: mov A,R4
Movc A,@A+DPTR
cpl A
Mov P1,A
call Delay
djnz R4,next2
mov P1,#0FFh
call delay
call delay
call delay
jmp mulai
;-------------------
; sub routine delay
;-------------------
Delay: DJNZ R3,delay ; R3=R3-1 bila <> 0 ke label delay
Djnz R1,Delay ; R1=R1-1 bila <> 0 ke label delay
Ret ; Kembali ke alamat setelah perintah
; 'call Delay'
LED_SATU:
DB 01h,02H,04H,08H,10H,20H,40H,80H
DB 81h,82h,84h,88h,90h,0B0h,0C0h
DB 0C1h,0C2h,0C4h,0C8h,0D0h,0E0h
DB 0E1h,0E2h,0E4h,0E8h,0F0h
DB 0F1h,0F2h,0F4h,0F8h
DB 0F9h,0FBh,0FCh
DB 0FDH,0FEh
DB 0FFh
End

Comments

Popular posts from this blog

Lirik Lagu Anak Na Lilu

ISTILAH DAN NAMA-NAMA WAKTU, HARI, DAN BULAN DALAM BAHASA BATAK (TOBA)

Lirik Lagu Batak