Mình dùng 6 led matrix nối với 6 IC 74HC595
Nối 8 chân phía dưới của từng led ma trận với các chân cổng P1(xuất dữ liệu hàng).
Sử dụng chân p2.0 nối chân dữ liệu của IC 74HC595. Chân P2.1 để điều khiển xung clock cho các IC.
Cứ mỗi lần đọc dữ liệu hàng ta lại cấp một xung tưng ứng để các IC dịch cho phép cột tương ứng sáng.
Các bạn tham khảo nha:
;su dung 74hc595 de quet cot
;p1 du lieu hang
INCLUDE 89c51.mc
hang equ p1
dulieu bit p2.0
clk BIT p2.1
org 0000h
CLR dulieu
CLR clk
main:
MOV DPTR,#code
ACALL taoxung
MOV R7,#00h
loop1: MOV R2,#5 ;so chu ky lap lai hay toc do quet
loop2: ;MOV R3,#48 ;48cot
MOV R1,#00 ;bien dem data
loop3:
CLR A ;quet 48 cot
MOV A,R1
movc a,@a+dptr
MOV hang ,A
ACALL delay
SETB clk
NOP
NOP
CLR clk
INC R1
CJNE R1,#49,loop3
ACALL taoxung ;quay tro lai quet tiep
DJNZ R2,loop2
inc dptr
mov a,dpl
INC R7
CJNE R7,#E1h,loop1
MOV hang,#0ffh
sjmp main
delay:mov R5,#2
delay1:
MOV R6,#255
DJNZ R6,$
DJNZ R5,delay1
RET
taoxung:setb dulieu
setb clk
NOP
NOP
CLR clk
clr dulieu
RET
org 0050h
code: DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH
DB 1H,7FH,7FH,7FH,0BFH ;L(6)
DB 0FFH,81H,7FH,7FH,7FH,81H ;U(6)
DB 0FFH,81H,7FH,7FH,7FH,81H,0FFH,0FFH ;U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,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH
Nối 8 chân phía dưới của từng led ma trận với các chân cổng P1(xuất dữ liệu hàng).
Sử dụng chân p2.0 nối chân dữ liệu của IC 74HC595. Chân P2.1 để điều khiển xung clock cho các IC.
Cứ mỗi lần đọc dữ liệu hàng ta lại cấp một xung tưng ứng để các IC dịch cho phép cột tương ứng sáng.
Các bạn tham khảo nha:
;su dung 74hc595 de quet cot
;p1 du lieu hang
INCLUDE 89c51.mc
hang equ p1
dulieu bit p2.0
clk BIT p2.1
org 0000h
CLR dulieu
CLR clk
main:
MOV DPTR,#code
ACALL taoxung
MOV R7,#00h
loop1: MOV R2,#5 ;so chu ky lap lai hay toc do quet
loop2: ;MOV R3,#48 ;48cot
MOV R1,#00 ;bien dem data
loop3:
CLR A ;quet 48 cot
MOV A,R1
movc a,@a+dptr
MOV hang ,A
ACALL delay
SETB clk
NOP
NOP
CLR clk
INC R1
CJNE R1,#49,loop3
ACALL taoxung ;quay tro lai quet tiep
DJNZ R2,loop2
inc dptr
mov a,dpl
INC R7
CJNE R7,#E1h,loop1
MOV hang,#0ffh
sjmp main
delay:mov R5,#2
delay1:
MOV R6,#255
DJNZ R6,$
DJNZ R5,delay1
RET
taoxung:setb dulieu
setb clk
NOP
NOP
CLR clk
clr dulieu
RET
org 0050h
code: DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,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