单片机程序8x8led点阵显示心形并实现左移右移的程序
使用的单片机仿真试验仪型号为DP-51PRO以下的程序是在8x8led显示频上显示一个心形我需要将它移动起来CLKEQUP3.2DINAEQUP3.3DINBEQUP3....
使用的单片机仿真试验仪型号为DP-51PRO
以下的程序是在8x8led显示频上显示一个心形
我需要将它移动起来
CLK EQU P3.2
DINA EQU P3.3
DINB EQU P3.4
CLEAR EQU P3.5
org 0000h
ajmp main
org 0100h
main:
mov sp,#70h
MOV 50H,#07EH
MOV 51H,#0BDH
MOV 52H,#0DBH
MOV 53H,#0E7H
MOV 54H,#0E7H
MOV 55H,#0DBH
MOV 56H,#0BDH
MOV 57H,#07EH
CLR CLEAR
SETB CLK
SETB DINA
SETB DINB
SETB CLEAR
mainloop:
mov r6,#8h
mov dptr,#09000h
MOV R1,#50H
flashcy:
MOV A,@R1
MOV R0,A
INC R1
clr a
movc a,@a+dptr
mov P1,0FFH
lcall sendto
mov P1,a
INC DPTR
LCALL DELAY
DJNZ R6,flashcy
sjmp mainloop
sendto:
PUSH ACC
CLR CLK
SENDTIME:
MOV R7,#08H
MOV A,R0
clr c
SENDCY:
RRC A
MOV DINA,C
SETB CLK
CLR CLK
DJNZ R7,SENDCY
POP ACC
RET
DELAY: MOV R7,#01
DELAY0: MOV R4,#17
DELAY1: MOV R3,#28
DJNZ R3,$
DJNZ R4,DELAY1
DJNZ R7,DELAY0
RET
org 09000h
db 0FEh,0FDh,0FBh,0F7h,0EFh,0DFh,0BFh,07Fh
end 展开
以下的程序是在8x8led显示频上显示一个心形
我需要将它移动起来
CLK EQU P3.2
DINA EQU P3.3
DINB EQU P3.4
CLEAR EQU P3.5
org 0000h
ajmp main
org 0100h
main:
mov sp,#70h
MOV 50H,#07EH
MOV 51H,#0BDH
MOV 52H,#0DBH
MOV 53H,#0E7H
MOV 54H,#0E7H
MOV 55H,#0DBH
MOV 56H,#0BDH
MOV 57H,#07EH
CLR CLEAR
SETB CLK
SETB DINA
SETB DINB
SETB CLEAR
mainloop:
mov r6,#8h
mov dptr,#09000h
MOV R1,#50H
flashcy:
MOV A,@R1
MOV R0,A
INC R1
clr a
movc a,@a+dptr
mov P1,0FFH
lcall sendto
mov P1,a
INC DPTR
LCALL DELAY
DJNZ R6,flashcy
sjmp mainloop
sendto:
PUSH ACC
CLR CLK
SENDTIME:
MOV R7,#08H
MOV A,R0
clr c
SENDCY:
RRC A
MOV DINA,C
SETB CLK
CLR CLK
DJNZ R7,SENDCY
POP ACC
RET
DELAY: MOV R7,#01
DELAY0: MOV R4,#17
DELAY1: MOV R3,#28
DJNZ R3,$
DJNZ R4,DELAY1
DJNZ R7,DELAY0
RET
org 09000h
db 0FEh,0FDh,0FBh,0F7h,0EFh,0DFh,0BFh,07Fh
end 展开
3个回答
展开全部
你用取模软件先点个心形,然后用字节左右移来实现就可以了
我有16*16点阵的各种动态效果程序
给你看下总共有12种动态效果,你改成8*8就可以了
/*************呈现各种显示效果的函数集****************/
void flash_bai(uchar *flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)//百叶窗效果
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(l=0;l<8;l++)
{
if(j<8)
{
dispram[l*4+1]=dispram[l*4+1]&0xff<<j|(flash_word[(flash_heard+i)*32+l*4]>>(7-j));
dispram[l*4+2]=dispram[l*4+2]&0xff>>j|(flash_word[(flash_heard+i)*32+l*4+3]<<(7-j)&0x10);
}
else
{
dispram[l*4] =dispram[l*4]&0xff<<(j-7)|flash_word[(flash_heard+i)*32+l*4]>>(15-j);
dispram[l*4+1]=flash_word[(flash_heard+i)*32+l*4]<<(j-7)|(flash_word[(flash_heard+i)*32+l*4+1]>>(15-j));
dispram[l*4+2]=flash_word[(flash_heard+i)*32+l*4+2]<<(15-j)|(flash_word[(flash_heard+i)*32+l*4+3]>>(j-7));
dispram[l*4+3]=(dispram[l*4+3]&0xff>>(j-7))|flash_word[(flash_heard+i)*32+l*4+3]<<(15-j);
}
}
delay(sdu*SPEED);
}
delay(state*SPEED);
}
}
/*******************霓虹灯效果************************/
void flash(uchar *flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<=16;j++)
{
for(k=17;k>j;k--)
{
for(l=0;l<16;l++)
{
if(j>8)
{
dispram[l*2] =1<<(8-k+j)|(flash_word[(flash_heard+i)*32+l*2]&0xff>>(16-j));
dispram[l*2+1]=flash_word[(flash_heard+i)*32+l*2+1];
}
else
{
dispram[l*2]=1<<(8-k+j);
dispram[l*2+1]=1<<(16-k+j)|(flash_word[(flash_heard+i)*32+l*2+1]&0xff>>(8-j));
}
}
delay(sdu*SPEED);
}
for(k=17;k>j;k--)
{
for(l=0;l<16;l++)
{
if(j>8)
{
dispram[l*2]=1<<(k-8)|(flash_word[(flash_heard+i)*32+l*2]&0xff>>(16-j));
}
else
{
dispram[l*2]=1<<(k-8);
dispram[l*2+1]=1<<k|(flash_word[(flash_heard+i)*32+l*2+1]&0xff>>(8-j));
}
}
delay(sdu*SPEED);
}
}
delay(state*SPEED);
}
}
/*******************跳动的米奇*********************/
void miqi_jump(void)
{uchar jump_i;
while((receive[1]&0x0f)<2)
{
switch (abc/7280)//(receive[0]&0x0f)%9
{
case 0:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2] = Bmp1[14][jump_i*2]<<1|Bmp1[14][jump_i*2+1]>>7;
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+1]<<1;//左移
}break;
case 1:for(jump_i=0;jump_i<15;jump_i++)
{dispram[0] = 0;
dispram[1] = 0;
dispram[jump_i*2+2] = Bmp1[14][jump_i*2];
dispram[jump_i*2+3] = Bmp1[14][jump_i*2+1];}
break;//下移
case 2:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+1]>>1|Bmp1[14][jump_i*2]<<7;
dispram[jump_i*2] = Bmp1[14][jump_i*2]>>1;
}break;//右移
case 3:for(jump_i=0;jump_i<15;jump_i++)
{dispram[30] = 0;
dispram[31] = 0;
dispram[jump_i*2] = Bmp1[14][jump_i*2+2];
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+3];}
break;//上移
case 4: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+2] = Bmp1[14][jump_i*2]<<1|Bmp1[14][jump_i*2+1]>>7;
dispram[jump_i*2+3] = Bmp1[14][jump_i*2+1]<<1;//左移
dispram[0] = 0;
dispram[1] = 0;
} break;//下移
case 5: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+3]>>1|Bmp1[14][jump_i*2+2]<<7;
dispram[jump_i*2] = Bmp1[14][jump_i*2+2]>>1;
dispram[30] = 0;
dispram[31] = 0;
} break;//上移
case 6: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+3] = Bmp1[14][jump_i*2+1]>>1|Bmp1[14][jump_i*2]<<7;
dispram[jump_i*2+2] = Bmp1[14][jump_i*2]>>1;
dispram[0] = 0;
dispram[1] = 0;
}
break;
case 7: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2] = Bmp1[14][jump_i*2+2]<<1|Bmp1[14][jump_i*2+3]>>7;
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+3]<<1;//左移
dispram[30] = 0;
dispram[31] = 0;
} break;
case 8:for(jump_i=0;jump_i<32;jump_i++)
dispram[jump_i] = Bmp1[14][jump_i];break;
}
}
}
/********从wordsp的第OpenDheard个字开始开门效果显示number个字**********/
//开门效果
void Open_door(uchar wordsp[][32],uchar OpenDheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff<<j|wordsp[OpenDheard+w][2*i]&0xff>>(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff>>j|wordsp[OpenDheard+w][1+2*i]&0xff<<(8-j);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/********从wordsp的第CloseDheard个字开始关门效果显示number个字**********/
//关门效果
void Close_door(uchar wordsp[][32],uchar CloseDheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[CloseDheard+w][2*i]&0xff<<(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[CloseDheard+w][1+2*i]&0xff>>(8-j);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/********从wordsp的第Far_Awayheard个字开始两边拉开显示number个字**********/
//两边拉开
void Far_Away(uchar wordsp[][32],uchar Far_Awayheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]<<j|wordsp[Far_Awayheard+w][2*i]&0xff>>(8-j);
dispram[i*2+1]=dispram[i*2+1]>>j|wordsp[Far_Awayheard+w][1+2*i]&0xff<<(8-j);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/********从wordsp的第Close_Toheard个字开始两边合拢显示number个字**********/
//两边合拢
void Close_To(uchar wordsp[][32],uchar Close_Toheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[Close_Toheard+w][2*i]<<(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[Close_Toheard+w][1+2*i]>>(8-j);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/****************卷帘出显示number个字***************/
//卷帘出显示
void M_Words(uchar *wordsp,uchar MWheard,uchar number,uchar sdu,uchar state)
{register uchar i,w;
for(w=0;w<number;w++)
{
for(i=0;i<32;i++)
{
dispram[i]=wordsp[(MWheard+w)*32+i];
if(i%2)
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/************从UP_Pullp的第UP_Pullheard个字向上拉出number个字***************/
//向上拉出
void UP_Pull_Word(uchar UP_Pullp[][32],uchar UP_Pullheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=0;k<15-j;k++)
{
dispram[k*2]=dispram[(k+1)*2];
dispram[k*2+1]=dispram[(k+1)*2+1];
}
dispram[30-2*j]=UP_Pullp[UP_Pullheard+i][(15-j)*2];
dispram[31-2*j]=UP_Pullp[UP_Pullheard+i][(15-j)*2+1];
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/*********从UPp的第UPheard个字向上滚屏number个字***************/
//向上滚屏
void UP_Run_Word(uchar UPp[][32],uchar UPheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=0;k<15;k++)
{
dispram[k*2]=dispram[(k+1)*2];
dispram[k*2+1]=dispram[(k+1)*2+1];
}
dispram[30]=UPp[UPheard+i][j*2];
dispram[31]=UPp[UPheard+i][j*2+1];
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/*********从Down_Pullp的第Down_Pullheard个字向下拉出number个字***************/
//向下拉出
void Down_Pull_Word(uchar Down_Pullp[][32],uchar Down_Pullheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=15;k>j;k--)
{
dispram[k*2]=dispram[(k-1)*2];
dispram[k*2+1]=dispram[(k-1)*2+1];
}
dispram[2*j]=Down_Pullp[Down_Pullheard+i][2*j];
dispram[2*j+1]=Down_Pullp[Down_Pullheard+i][2*j+1];
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/*********从Downp的第UPheard个字向下滚屏number个字***************/
//向下滚屏
void Down_Run_Word(uchar *Downp,uchar UPheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=15;k>0;k--)
{
dispram[k*2]=dispram[(k-1)*2];
dispram[k*2+1]=dispram[(k-1)*2+1];
}
dispram[0]=Downp[(UPheard+i)*32+(15-j)*2];
dispram[1]=Downp[(UPheard+i)*32+(15-j)*2+1];
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/**********从LRp的第LRheard个字左移出显示number个字************/
//用左移出显示
void L_Removeout_Word(uchar *LRp,uchar LRheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<2;j++)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
dispram[l*2]=dispram[l*2]<<1|dispram[l*2+1]>>7;
dispram[l*2+1]=dispram[l*2+1]<<1|LRp[(i+LRheard)*32+l*2+j]>>(7-k);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/**********从L_Pullp的第L_Pullheard个字左拉出显示number个字************/
//左拉出显示
void L_Pull_Word(uchar *L_Pullp,uchar L_Pullheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<2;j++)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
if(j==0)
{
dispram[l*2]=dispram[l*2]<<1|dispram[l*2+1]>>7;
dispram[l*2+1]=(dispram[l*2+1]&0xff<<(k+1))<<1|L_Pullp[(i+L_Pullheard)*32+l*2+1]&0xff>>(7-k);
}
else
{
dispram[l*2]=(dispram[l*2]&0xff<<(k+1))<<1|L_Pullp[(i+L_Pullheard)*32+l*2]&0xff>>(7-k);
dispram[l*2+1]=L_Pullp[(i+L_Pullheard)*32+l*2+1];
}
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/****************卷帘出黑屏***************/
void M_Black(void)
{register uchar i;
for(i=0;i<32;i++)
{
dispram[i]=0x00;
if(i%2)
delay(5*SPEED);
}
}
/**********从RRp的第RRheard个字右移出显示number个字************/
//右移出显示
void R_Removeout_Word(uchar *RRp,uchar RRheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=2;j>0;j--)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
dispram[l*2+1]=dispram[l*2+1]>>1|dispram[l*2]<<7;
dispram[l*2]=dispram[l*2]>>1|RRp[(i+RRheard)*32+l*2+j-1]<<(7-k);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/**************随机跑动函数**************/
void radom_flash(uchar *Radom_p,uchar Radom_heard,uchar number,uchar sdu,uchar state)
{
switch ((receive[1]&0x0f)+(receive[0]&0x70)/16)
{
case 0: Open_door(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//开门
case 1: Close_door(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//关门
case 2: Far_Away(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//分开
case 3: Close_To(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//合拢
case 4: miqi_jump();
case 5: M_Words(Radom_p,Radom_heard,number,sdu,state);M_Black(); break;//卷帘
case 6: UP_Pull_Word(Radom_p,Radom_heard,number,sdu,state);break;//上拉出
case 7: UP_Run_Word(Radom_p,Radom_heard,number,sdu,state);break;//上滚屏
case 8: Down_Pull_Word(Radom_p,Radom_heard,number,sdu,state);break;//下拉出
case 9: Down_Run_Word(Radom_p,Radom_heard,number,sdu,state);break;
case 10: L_Removeout_Word(Radom_p,Radom_heard,number,sdu,state);break;//左滚屏
case 11: L_Pull_Word(Radom_p,Radom_heard,number,sdu,state);break;//左拉出
case 12: R_Removeout_Word(Radom_p,Radom_heard,number,sdu,state);break;//右滚屏
case 13: flash(Radom_p,Radom_heard,number,3,state);break;
case 14: flash_bai(Radom_p,Radom_heard,number,sdu,state);break;
}
}
我有16*16点阵的各种动态效果程序
给你看下总共有12种动态效果,你改成8*8就可以了
/*************呈现各种显示效果的函数集****************/
void flash_bai(uchar *flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)//百叶窗效果
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(l=0;l<8;l++)
{
if(j<8)
{
dispram[l*4+1]=dispram[l*4+1]&0xff<<j|(flash_word[(flash_heard+i)*32+l*4]>>(7-j));
dispram[l*4+2]=dispram[l*4+2]&0xff>>j|(flash_word[(flash_heard+i)*32+l*4+3]<<(7-j)&0x10);
}
else
{
dispram[l*4] =dispram[l*4]&0xff<<(j-7)|flash_word[(flash_heard+i)*32+l*4]>>(15-j);
dispram[l*4+1]=flash_word[(flash_heard+i)*32+l*4]<<(j-7)|(flash_word[(flash_heard+i)*32+l*4+1]>>(15-j));
dispram[l*4+2]=flash_word[(flash_heard+i)*32+l*4+2]<<(15-j)|(flash_word[(flash_heard+i)*32+l*4+3]>>(j-7));
dispram[l*4+3]=(dispram[l*4+3]&0xff>>(j-7))|flash_word[(flash_heard+i)*32+l*4+3]<<(15-j);
}
}
delay(sdu*SPEED);
}
delay(state*SPEED);
}
}
/*******************霓虹灯效果************************/
void flash(uchar *flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<=16;j++)
{
for(k=17;k>j;k--)
{
for(l=0;l<16;l++)
{
if(j>8)
{
dispram[l*2] =1<<(8-k+j)|(flash_word[(flash_heard+i)*32+l*2]&0xff>>(16-j));
dispram[l*2+1]=flash_word[(flash_heard+i)*32+l*2+1];
}
else
{
dispram[l*2]=1<<(8-k+j);
dispram[l*2+1]=1<<(16-k+j)|(flash_word[(flash_heard+i)*32+l*2+1]&0xff>>(8-j));
}
}
delay(sdu*SPEED);
}
for(k=17;k>j;k--)
{
for(l=0;l<16;l++)
{
if(j>8)
{
dispram[l*2]=1<<(k-8)|(flash_word[(flash_heard+i)*32+l*2]&0xff>>(16-j));
}
else
{
dispram[l*2]=1<<(k-8);
dispram[l*2+1]=1<<k|(flash_word[(flash_heard+i)*32+l*2+1]&0xff>>(8-j));
}
}
delay(sdu*SPEED);
}
}
delay(state*SPEED);
}
}
/*******************跳动的米奇*********************/
void miqi_jump(void)
{uchar jump_i;
while((receive[1]&0x0f)<2)
{
switch (abc/7280)//(receive[0]&0x0f)%9
{
case 0:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2] = Bmp1[14][jump_i*2]<<1|Bmp1[14][jump_i*2+1]>>7;
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+1]<<1;//左移
}break;
case 1:for(jump_i=0;jump_i<15;jump_i++)
{dispram[0] = 0;
dispram[1] = 0;
dispram[jump_i*2+2] = Bmp1[14][jump_i*2];
dispram[jump_i*2+3] = Bmp1[14][jump_i*2+1];}
break;//下移
case 2:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+1]>>1|Bmp1[14][jump_i*2]<<7;
dispram[jump_i*2] = Bmp1[14][jump_i*2]>>1;
}break;//右移
case 3:for(jump_i=0;jump_i<15;jump_i++)
{dispram[30] = 0;
dispram[31] = 0;
dispram[jump_i*2] = Bmp1[14][jump_i*2+2];
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+3];}
break;//上移
case 4: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+2] = Bmp1[14][jump_i*2]<<1|Bmp1[14][jump_i*2+1]>>7;
dispram[jump_i*2+3] = Bmp1[14][jump_i*2+1]<<1;//左移
dispram[0] = 0;
dispram[1] = 0;
} break;//下移
case 5: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+3]>>1|Bmp1[14][jump_i*2+2]<<7;
dispram[jump_i*2] = Bmp1[14][jump_i*2+2]>>1;
dispram[30] = 0;
dispram[31] = 0;
} break;//上移
case 6: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+3] = Bmp1[14][jump_i*2+1]>>1|Bmp1[14][jump_i*2]<<7;
dispram[jump_i*2+2] = Bmp1[14][jump_i*2]>>1;
dispram[0] = 0;
dispram[1] = 0;
}
break;
case 7: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2] = Bmp1[14][jump_i*2+2]<<1|Bmp1[14][jump_i*2+3]>>7;
dispram[jump_i*2+1] = Bmp1[14][jump_i*2+3]<<1;//左移
dispram[30] = 0;
dispram[31] = 0;
} break;
case 8:for(jump_i=0;jump_i<32;jump_i++)
dispram[jump_i] = Bmp1[14][jump_i];break;
}
}
}
/********从wordsp的第OpenDheard个字开始开门效果显示number个字**********/
//开门效果
void Open_door(uchar wordsp[][32],uchar OpenDheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff<<j|wordsp[OpenDheard+w][2*i]&0xff>>(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff>>j|wordsp[OpenDheard+w][1+2*i]&0xff<<(8-j);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/********从wordsp的第CloseDheard个字开始关门效果显示number个字**********/
//关门效果
void Close_door(uchar wordsp[][32],uchar CloseDheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[CloseDheard+w][2*i]&0xff<<(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[CloseDheard+w][1+2*i]&0xff>>(8-j);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/********从wordsp的第Far_Awayheard个字开始两边拉开显示number个字**********/
//两边拉开
void Far_Away(uchar wordsp[][32],uchar Far_Awayheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]<<j|wordsp[Far_Awayheard+w][2*i]&0xff>>(8-j);
dispram[i*2+1]=dispram[i*2+1]>>j|wordsp[Far_Awayheard+w][1+2*i]&0xff<<(8-j);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/********从wordsp的第Close_Toheard个字开始两边合拢显示number个字**********/
//两边合拢
void Close_To(uchar wordsp[][32],uchar Close_Toheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[Close_Toheard+w][2*i]<<(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[Close_Toheard+w][1+2*i]>>(8-j);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/****************卷帘出显示number个字***************/
//卷帘出显示
void M_Words(uchar *wordsp,uchar MWheard,uchar number,uchar sdu,uchar state)
{register uchar i,w;
for(w=0;w<number;w++)
{
for(i=0;i<32;i++)
{
dispram[i]=wordsp[(MWheard+w)*32+i];
if(i%2)
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/************从UP_Pullp的第UP_Pullheard个字向上拉出number个字***************/
//向上拉出
void UP_Pull_Word(uchar UP_Pullp[][32],uchar UP_Pullheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=0;k<15-j;k++)
{
dispram[k*2]=dispram[(k+1)*2];
dispram[k*2+1]=dispram[(k+1)*2+1];
}
dispram[30-2*j]=UP_Pullp[UP_Pullheard+i][(15-j)*2];
dispram[31-2*j]=UP_Pullp[UP_Pullheard+i][(15-j)*2+1];
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/*********从UPp的第UPheard个字向上滚屏number个字***************/
//向上滚屏
void UP_Run_Word(uchar UPp[][32],uchar UPheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=0;k<15;k++)
{
dispram[k*2]=dispram[(k+1)*2];
dispram[k*2+1]=dispram[(k+1)*2+1];
}
dispram[30]=UPp[UPheard+i][j*2];
dispram[31]=UPp[UPheard+i][j*2+1];
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/*********从Down_Pullp的第Down_Pullheard个字向下拉出number个字***************/
//向下拉出
void Down_Pull_Word(uchar Down_Pullp[][32],uchar Down_Pullheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=15;k>j;k--)
{
dispram[k*2]=dispram[(k-1)*2];
dispram[k*2+1]=dispram[(k-1)*2+1];
}
dispram[2*j]=Down_Pullp[Down_Pullheard+i][2*j];
dispram[2*j+1]=Down_Pullp[Down_Pullheard+i][2*j+1];
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/*********从Downp的第UPheard个字向下滚屏number个字***************/
//向下滚屏
void Down_Run_Word(uchar *Downp,uchar UPheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=15;k>0;k--)
{
dispram[k*2]=dispram[(k-1)*2];
dispram[k*2+1]=dispram[(k-1)*2+1];
}
dispram[0]=Downp[(UPheard+i)*32+(15-j)*2];
dispram[1]=Downp[(UPheard+i)*32+(15-j)*2+1];
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/**********从LRp的第LRheard个字左移出显示number个字************/
//用左移出显示
void L_Removeout_Word(uchar *LRp,uchar LRheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<2;j++)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
dispram[l*2]=dispram[l*2]<<1|dispram[l*2+1]>>7;
dispram[l*2+1]=dispram[l*2+1]<<1|LRp[(i+LRheard)*32+l*2+j]>>(7-k);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/**********从L_Pullp的第L_Pullheard个字左拉出显示number个字************/
//左拉出显示
void L_Pull_Word(uchar *L_Pullp,uchar L_Pullheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<2;j++)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
if(j==0)
{
dispram[l*2]=dispram[l*2]<<1|dispram[l*2+1]>>7;
dispram[l*2+1]=(dispram[l*2+1]&0xff<<(k+1))<<1|L_Pullp[(i+L_Pullheard)*32+l*2+1]&0xff>>(7-k);
}
else
{
dispram[l*2]=(dispram[l*2]&0xff<<(k+1))<<1|L_Pullp[(i+L_Pullheard)*32+l*2]&0xff>>(7-k);
dispram[l*2+1]=L_Pullp[(i+L_Pullheard)*32+l*2+1];
}
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/****************卷帘出黑屏***************/
void M_Black(void)
{register uchar i;
for(i=0;i<32;i++)
{
dispram[i]=0x00;
if(i%2)
delay(5*SPEED);
}
}
/**********从RRp的第RRheard个字右移出显示number个字************/
//右移出显示
void R_Removeout_Word(uchar *RRp,uchar RRheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=2;j>0;j--)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
dispram[l*2+1]=dispram[l*2+1]>>1|dispram[l*2]<<7;
dispram[l*2]=dispram[l*2]>>1|RRp[(i+RRheard)*32+l*2+j-1]<<(7-k);
}
delay(sdu*SPEED);
}
delay(state*TIME);
}
}
/**************随机跑动函数**************/
void radom_flash(uchar *Radom_p,uchar Radom_heard,uchar number,uchar sdu,uchar state)
{
switch ((receive[1]&0x0f)+(receive[0]&0x70)/16)
{
case 0: Open_door(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//开门
case 1: Close_door(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//关门
case 2: Far_Away(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//分开
case 3: Close_To(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//合拢
case 4: miqi_jump();
case 5: M_Words(Radom_p,Radom_heard,number,sdu,state);M_Black(); break;//卷帘
case 6: UP_Pull_Word(Radom_p,Radom_heard,number,sdu,state);break;//上拉出
case 7: UP_Run_Word(Radom_p,Radom_heard,number,sdu,state);break;//上滚屏
case 8: Down_Pull_Word(Radom_p,Radom_heard,number,sdu,state);break;//下拉出
case 9: Down_Run_Word(Radom_p,Radom_heard,number,sdu,state);break;
case 10: L_Removeout_Word(Radom_p,Radom_heard,number,sdu,state);break;//左滚屏
case 11: L_Pull_Word(Radom_p,Radom_heard,number,sdu,state);break;//左拉出
case 12: R_Removeout_Word(Radom_p,Radom_heard,number,sdu,state);break;//右滚屏
case 13: flash(Radom_p,Radom_heard,number,3,state);break;
case 14: flash_bai(Radom_p,Radom_heard,number,sdu,state);break;
}
}
展开全部
你先把“静止显示”的程序贴出来。
-------------------
楼主给出的程序,显示图案是个“×”,对吗?
-------------------
程序如下:
;//=========================
ORG 0000H
CLK EQU P3.2
DINA EQU P3.3
DINB EQU P3.4
CLEAR EQU P3.5
org 0000h
ajmp main
org 0100h
main:
mov sp, #70h
MOV 50H,#07EH
MOV 51H,#0BDH
MOV 52H,#0DBH
MOV 53H,#0E7H
MOV 54H,#0E7H
MOV 55H,#0DBH
MOV 56H,#0BDH
MOV 57H,#07EH
;//-------------------------
CLR CLEAR
SETB CLK
SETB DINA
SETB DINB
SETB CLEAR
MOV 30H, #10
LOOP:
ACALL DISP500MS
DJNZ 30H, $ - 2
CALL ZUOYI
CALL ZUOYI
LJMP main
;//-------------------------
ZUOYI:
MOV 30H, #8
ACALL _LEFT_
ACALL DISP500MS
DJNZ 30H, $ - 4
RET
;//-------------------------
_LEFT_:
MOV R0, #50H
MOV R1, #51H
MOV B, 50H
MOV R2, #7
L_LOOP:
MOV A, @R1
MOV @R0, A
INC R0
INC R1
DJNZ R2, L_LOOP
MOV 57H, B
RET
;//-------------------------
DISP500MS:
MOV R5, #60
ACALL mainloop
DJNZ R5, $ - 2
RET
;//-------------------------
mainloop:
mov b, #0FEh
MOV R1, #50H
mov r6, #8
flashcy:
MOV A, @R1
INC R1
lcall sendto
mov P1, b
mov a, b
rl a
mov b, a
LCALL DELAY
DJNZ R6, flashcy
RET
;//-------------------------
sendto:
CLR CLK
SENDTIME:
MOV R7, #08H
SENDCY:
RRC A
MOV DINA, C
SETB CLK
CLR CLK
DJNZ R7, SENDCY
RET
;//-------------------------
DELAY: MOV R7, #01
DELAY0: MOV R4, #17
DELAY1: MOV R3, #28
DJNZ R3,$
DJNZ R4,DELAY1
DJNZ R7,DELAY0
RET
;//-------------------------
end
;//=========================
-------------------
楼主给出的程序,显示图案是个“×”,对吗?
-------------------
程序如下:
;//=========================
ORG 0000H
CLK EQU P3.2
DINA EQU P3.3
DINB EQU P3.4
CLEAR EQU P3.5
org 0000h
ajmp main
org 0100h
main:
mov sp, #70h
MOV 50H,#07EH
MOV 51H,#0BDH
MOV 52H,#0DBH
MOV 53H,#0E7H
MOV 54H,#0E7H
MOV 55H,#0DBH
MOV 56H,#0BDH
MOV 57H,#07EH
;//-------------------------
CLR CLEAR
SETB CLK
SETB DINA
SETB DINB
SETB CLEAR
MOV 30H, #10
LOOP:
ACALL DISP500MS
DJNZ 30H, $ - 2
CALL ZUOYI
CALL ZUOYI
LJMP main
;//-------------------------
ZUOYI:
MOV 30H, #8
ACALL _LEFT_
ACALL DISP500MS
DJNZ 30H, $ - 4
RET
;//-------------------------
_LEFT_:
MOV R0, #50H
MOV R1, #51H
MOV B, 50H
MOV R2, #7
L_LOOP:
MOV A, @R1
MOV @R0, A
INC R0
INC R1
DJNZ R2, L_LOOP
MOV 57H, B
RET
;//-------------------------
DISP500MS:
MOV R5, #60
ACALL mainloop
DJNZ R5, $ - 2
RET
;//-------------------------
mainloop:
mov b, #0FEh
MOV R1, #50H
mov r6, #8
flashcy:
MOV A, @R1
INC R1
lcall sendto
mov P1, b
mov a, b
rl a
mov b, a
LCALL DELAY
DJNZ R6, flashcy
RET
;//-------------------------
sendto:
CLR CLK
SENDTIME:
MOV R7, #08H
SENDCY:
RRC A
MOV DINA, C
SETB CLK
CLR CLK
DJNZ R7, SENDCY
RET
;//-------------------------
DELAY: MOV R7, #01
DELAY0: MOV R4, #17
DELAY1: MOV R3, #28
DJNZ R3,$
DJNZ R4,DELAY1
DJNZ R7,DELAY0
RET
;//-------------------------
end
;//=========================
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
百度知道 > 电脑/网络 > 程序设计 > 其他编程语言添加到搜藏待解决
检举 单片机程序8x8led点阵显示心形并实现左移右移的程序
悬赏分:20 - 离问题结束还有 14 天 23 小时
使用的单片机仿真试验仪型号为DP-51PRO
检举 单片机程序8x8led点阵显示心形并实现左移右移的程序
悬赏分:20 - 离问题结束还有 14 天 23 小时
使用的单片机仿真试验仪型号为DP-51PRO
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询