请问谁有用单片机AT89c5274HC595做列扫描、4HC164做行扫描,做成的16X16点阵LED显示屏的程序?急用,谢谢
芯片AT89S52的引脚21、22、23、25、26分别接74HC595的14、11、12,74HC164的1、8。...
芯片AT89S52的引脚21、22、23、25、26分别接74HC595的14、11、12,74HC164的1、8。
展开
2个回答
2010-11-17
展开全部
我的空间有程序,你去看看,有十几种移动方法
屏幕点阵数的话也可以随时改动的
/*************呈现各种显示效果的函数集****************/
void flash_bai(uchar *flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)
{register uchar i,j,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)
{register uchar jump_i;
while((receive[1]&0x0f)<2)//
{
switch (timer/3650)
{
case 0:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2] = word1[11][jump_i*2]<<1|word1[11][jump_i*2+1]>>7;
dispram[jump_i*2+1] = word1[11][jump_i*2+1]<<1;//左移
}break;
case 1:for(jump_i=0;jump_i<15;jump_i++)
{
dispram[jump_i*2+2] = word1[11][jump_i*2];
dispram[jump_i*2+3] = word1[11][jump_i*2+1];
}
dispram[0] = 0;
dispram[1] = 0;
break;//下移
case 2:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+1] = word1[11][jump_i*2+1]>>1|word1[11][jump_i*2]<<7;
dispram[jump_i*2] = word1[11][jump_i*2]>>1;
}break;//右移
case 3:for(jump_i=0;jump_i<15;jump_i++)
{
dispram[jump_i*2] = word1[11][jump_i*2+2];
dispram[jump_i*2+1] = word1[11][jump_i*2+3];
}
dispram[30] = 0;
dispram[31] = 0;
break;//上移
case 4: for(jump_i=0;jump_i<15;jump_i++)
{
dispram[jump_i*2+2] = word1[11][jump_i*2]<<1|word1[11][jump_i*2+1]>>7;
dispram[jump_i*2+3] = word1[11][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] = word1[11][jump_i*2+3]>>1|word1[11][jump_i*2+2]<<7;
dispram[jump_i*2] = word1[11][jump_i*2+2]>>1;
}dispram[30] = 0;
dispram[31] = 0;
break;//上移
case 6: for(jump_i=0;jump_i<15;jump_i++)
{
dispram[jump_i*2+3] = word1[11][jump_i*2+1]>>1|word1[11][jump_i*2]<<7;
dispram[jump_i*2+2] = word1[11][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] = word1[11][jump_i*2+2]<<1|word1[11][jump_i*2+3]>>7;
dispram[jump_i*2+1] = word1[11][jump_i*2+3]<<1;//左移
}
dispram[30] = 0;
dispram[31] = 0;
break;
default:for(jump_i=0;jump_i<32;jump_i++)
dispram[jump_i] = word1[11][jump_i];
}
}
}
/********从wordsp的第OpenDheard个字开始开门效果显示number个字**********/
//用数组更加节省空间
void Open_door(uchar wordsp[][32],uchar OpenDheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(k=0;k<number;k++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff<<j|wordsp[OpenDheard+k][2*i]&0xff>>(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff>>j|wordsp[OpenDheard+k][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,k;
for(k=0;k<number;k++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[CloseDheard+k][2*i]&0xff<<(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[CloseDheard+k][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,k;
for(k=0;k<number;k++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]<<j|wordsp[Far_Awayheard+k][2*i]&0xff>>(8-j);
dispram[i*2+1]=dispram[i*2+1]>>j|wordsp[Far_Awayheard+k][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,k;
for(k=0;k<number;k++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[Close_Toheard+k][2*i]<<(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[Close_Toheard+k][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,j;
for(j=0;j<number;j++)
{
for(i=0;i<32;i++)
{
dispram[i]=wordsp[(MWheard+j)*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 flash_bai(uchar *flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)
{register uchar i,j,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)
{register uchar jump_i;
while((receive[1]&0x0f)<2)//
{
switch (timer/3650)
{
case 0:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2] = word1[11][jump_i*2]<<1|word1[11][jump_i*2+1]>>7;
dispram[jump_i*2+1] = word1[11][jump_i*2+1]<<1;//左移
}break;
case 1:for(jump_i=0;jump_i<15;jump_i++)
{
dispram[jump_i*2+2] = word1[11][jump_i*2];
dispram[jump_i*2+3] = word1[11][jump_i*2+1];
}
dispram[0] = 0;
dispram[1] = 0;
break;//下移
case 2:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i*2+1] = word1[11][jump_i*2+1]>>1|word1[11][jump_i*2]<<7;
dispram[jump_i*2] = word1[11][jump_i*2]>>1;
}break;//右移
case 3:for(jump_i=0;jump_i<15;jump_i++)
{
dispram[jump_i*2] = word1[11][jump_i*2+2];
dispram[jump_i*2+1] = word1[11][jump_i*2+3];
}
dispram[30] = 0;
dispram[31] = 0;
break;//上移
case 4: for(jump_i=0;jump_i<15;jump_i++)
{
dispram[jump_i*2+2] = word1[11][jump_i*2]<<1|word1[11][jump_i*2+1]>>7;
dispram[jump_i*2+3] = word1[11][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] = word1[11][jump_i*2+3]>>1|word1[11][jump_i*2+2]<<7;
dispram[jump_i*2] = word1[11][jump_i*2+2]>>1;
}dispram[30] = 0;
dispram[31] = 0;
break;//上移
case 6: for(jump_i=0;jump_i<15;jump_i++)
{
dispram[jump_i*2+3] = word1[11][jump_i*2+1]>>1|word1[11][jump_i*2]<<7;
dispram[jump_i*2+2] = word1[11][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] = word1[11][jump_i*2+2]<<1|word1[11][jump_i*2+3]>>7;
dispram[jump_i*2+1] = word1[11][jump_i*2+3]<<1;//左移
}
dispram[30] = 0;
dispram[31] = 0;
break;
default:for(jump_i=0;jump_i<32;jump_i++)
dispram[jump_i] = word1[11][jump_i];
}
}
}
/********从wordsp的第OpenDheard个字开始开门效果显示number个字**********/
//用数组更加节省空间
void Open_door(uchar wordsp[][32],uchar OpenDheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(k=0;k<number;k++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff<<j|wordsp[OpenDheard+k][2*i]&0xff>>(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff>>j|wordsp[OpenDheard+k][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,k;
for(k=0;k<number;k++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[CloseDheard+k][2*i]&0xff<<(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[CloseDheard+k][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,k;
for(k=0;k<number;k++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]<<j|wordsp[Far_Awayheard+k][2*i]&0xff>>(8-j);
dispram[i*2+1]=dispram[i*2+1]>>j|wordsp[Far_Awayheard+k][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,k;
for(k=0;k<number;k++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[Close_Toheard+k][2*i]<<(8-j);
dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[Close_Toheard+k][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,j;
for(j=0;j<number;j++)
{
for(i=0;i<32;i++)
{
dispram[i]=wordsp[(MWheard+j)*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);
}
}
展开全部
就是这个,自己亲手做的,仿真能显示
#include"reg52.h"
#define uchar unsigned char
#define uint unsigned int
#define hang P1
#define address P2
sbit datas=P3^0;
sbit stcp=P3^1;
sbit shcp=P3^2;
uchar zhongguo[]={ 0x00,0x00,0xFF,0xFE,0x40,0x02,0x48,0x0A,0x48,0x8A,0x48,0x8A,0x48,0x8A,0x4F,0xFA,
0x48,0x8A,0x49,0x8A,0x4E,0x8A,0x48,0x0A,0x40,0x02,0xFF,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0xFC,0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0xFF,0xFF,
0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0x07,0xFC,0x00,0x08,0x00,0x00,0x00,0x00};//汉字 中国 的点阵
void delay()
{
uint i;
for(i=0;i<150;i++)
;
}
void datasend(uchar num) //用了74HC595移位寄存器,用这个函数来发送数据
{
uint i;
stcp=0;
for(i=0;i<8;i++)
{
shcp=0;
if((num&0x01)!=0)
datas=1;
else
datas=0;
shcp=1;
;
;
shcp=0;
num>>=1;
}
stcp=1;
}
void dynamicdisplay(uchar num[] ) //动态显示函数(从左到右)
{ uchar j,h;
uchar k;
char i;
i=15;
j=32;
k=0;
h=32;
while(1)
{
while(k<20)
{
while(i>=0)
{
hang=i;
address=0x01;
datasend(num[j]);
delay();
j++;
address=0x00;
datasend(num[j]);
j++;
delay();
i--;
}
i=15;
j=h;
k++;
}
i=15;
h=h-2;
j=h;
k=0;
}
}
void staticdisplay(uchar num[]) //静态显示
{
uchar j;
uchar i;
i=15;
j=0;
while(1)
{
while(i>7)
{
hang=i;
address=0x01;
datasend(num[j]);
delay2();
j++;
address=0x00;
datasend(num[j]);
j++;
delay();
i--;
}
i=15;
j=0;
}
}
void main()
{
dynamicdisplay( zhongguo );
}
#include"reg52.h"
#define uchar unsigned char
#define uint unsigned int
#define hang P1
#define address P2
sbit datas=P3^0;
sbit stcp=P3^1;
sbit shcp=P3^2;
uchar zhongguo[]={ 0x00,0x00,0xFF,0xFE,0x40,0x02,0x48,0x0A,0x48,0x8A,0x48,0x8A,0x48,0x8A,0x4F,0xFA,
0x48,0x8A,0x49,0x8A,0x4E,0x8A,0x48,0x0A,0x40,0x02,0xFF,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0xFC,0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0xFF,0xFF,
0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0x07,0xFC,0x00,0x08,0x00,0x00,0x00,0x00};//汉字 中国 的点阵
void delay()
{
uint i;
for(i=0;i<150;i++)
;
}
void datasend(uchar num) //用了74HC595移位寄存器,用这个函数来发送数据
{
uint i;
stcp=0;
for(i=0;i<8;i++)
{
shcp=0;
if((num&0x01)!=0)
datas=1;
else
datas=0;
shcp=1;
;
;
shcp=0;
num>>=1;
}
stcp=1;
}
void dynamicdisplay(uchar num[] ) //动态显示函数(从左到右)
{ uchar j,h;
uchar k;
char i;
i=15;
j=32;
k=0;
h=32;
while(1)
{
while(k<20)
{
while(i>=0)
{
hang=i;
address=0x01;
datasend(num[j]);
delay();
j++;
address=0x00;
datasend(num[j]);
j++;
delay();
i--;
}
i=15;
j=h;
k++;
}
i=15;
h=h-2;
j=h;
k=0;
}
}
void staticdisplay(uchar num[]) //静态显示
{
uchar j;
uchar i;
i=15;
j=0;
while(1)
{
while(i>7)
{
hang=i;
address=0x01;
datasend(num[j]);
delay2();
j++;
address=0x00;
datasend(num[j]);
j++;
delay();
i--;
}
i=15;
j=0;
}
}
void main()
{
dynamicdisplay( zhongguo );
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询