mong các bạn viết giúp mình chương trình 32led sáng dồn.
thank các bạn trước nha.
thank các bạn trước nha.
// cntt thai nguyen // duoc viet boi nhom handinhand dtvtk7a #include<reg52.h> #include<stdio.h> #include<intrins.h> unsigned int i,j,k; void delay(unsigned int ms) { unsigned int a; unsigned char b; for(a=0;a<ms;a++) { for(b=0;b<125;b++) { } } } void ok(void) { unsigned char mang[36]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, 0x81,0x82,0x84,0x88,0x90,0xA0,0xC0,0xC1, 0xC2,0xC4,0xC8,0xD0,0xE0,0xE1,0xE2,0xE4, 0xE8,0xF0,0xF1,0xF2,0xF4,0xF8,0xF9,0xFA, 0xFC,0xFD,0xFE,0xFF}; for(i=0;i<37;i++) //8 //8 //8 //8 //5 { P1=mang[i]; delay(500); } } void main(void) { while(1) { ok(); } }
org 00h td: ;----------------------------------------------------------------------------*1 mov p0,#0ffh mov p1,#0ffh mov p2,#0ffh mov p3,#0ffh lcall delay k: clr c mov a,p0 rlc a mov p0,a mov a,p1 rlc a mov p1,a mov a,p3 rlc a mov p3,a mov a,p2 rlc a mov p2,a lcall delay jc k jmp td ;**************** delay: mov 32h,#1 mov 33h,#200 mov 34h,#180 jj: djnz 34h,jj djnz 33h,jj djnz 32h,jj ret ;**************** end
org 00h td: ;----------------------------------------------------------------------------*1 mov p0,#0ffh mov p1,#0ffh mov p2,#0ffh mov p3,#0ffh lcall delay k: clr c mov a,p0 rlc a mov p0,a mov a,p1 rlc a mov p1,a mov a,p3 rlc a mov p3,a mov a,p2 rlc a mov p2,a lcall delay jc k jmp td ;**************** delay: mov 32h,#1 mov 33h,#200 mov 34h,#180 jj: djnz 34h,jj djnz 33h,jj djnz 32h,jj ret ;**************** end
Comment