帮忙看下16x64点阵显示时最上面一行跑到最下面一行

2019-07-15 12:02发布

QQ截图20170205164022.png
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int

sbit DS=P2^0;  //串行时钟
sbit SH=P2^1;  //串行数据输入
sbit ST=P2^2;  //数据锁存
sbit A1=P2^3;
sbit A2=P2^4;
sbit A3=P2^5;
sbit A4=P2^6;  //138译码器



uchar code H[]=
{

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*--  文字:  电  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x20,0x20,0x10,0x30,0x18,0x30,0x10,0x32,
      0x0B,0xFF,0x7C,0x30,0x18,0x30,0x18,0x78,
      0x18,0x78,0x18,0xCC,0x19,0x8E,0x1B,0x07,
      0x1C,0x02,0x36,0x00,0x63,0xFF,0x21,0xFE,

/*--  文字:  子  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0x3F,0xF0,0x00,0x20,0x00,0x40,0x00,0x80,0x01,0x00,0x01,0x00,0x01,0x04,
0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,

/*--  文字:  爱  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0xF8,0x3F,0x90,0x12,0x10,0x09,0x20,0x3F,0xFE,0x22,0x02,0x42,0x00,0x3F,0xFC,
0x04,0x00,0x07,0xF0,0x0C,0x20,0x0B,0x40,0x10,0xC0,0x63,0x30,0x8C,0x0E,0x30,0x04,

/*--  文字:  好  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x00,0x11,0xFC,0x10,0x08,0x10,0x10,0xFC,0x20,0x24,0x20,0x24,0x20,0x27,0xFE,
0x44,0x20,0x64,0x20,0x18,0x20,0x08,0x20,0x14,0x20,0x26,0x20,0x44,0xA0,0x80,0x40,

/******************************************************************************/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};


uchar BUFF[10];   //缓冲数组


void read(uchar dat)  
{
     uchar i;
     for(i=0;i<8;i++)
     {
         DS=(dat&0x80)?1:0;  //判断最高位,为真取1,为假取0
         SH=1;        //上升沿送数据
         SH=0;
         dat=dat<<1;  //左移取下一位
     }   
}//写入数据

void buff(uchar h,uchar word)
{
    uchar i;
    for(i=0;i<5;i++)
    {
        BUFF[2*i]=H[word*32+32*i+h*2];
        BUFF[2*i+1]=H[word*32+32*i+h*2+1];
    }
}//预先缓冲5个字

void move(uchar k)
{
    uchar i,temp,u8;
    if(k>=8)
    {
         k=k-8;
         u8=1;
    }
    else
         u8=0;
    for(i=0+u8;i<8+u8;i++)
    {
         temp=(BUFF<<k)|(BUFF[i+1]>>(8-k));
         read(temp);
    }
}//向左移动

int main(void)
{ uchar i=0,k=0,l=0,word=0;
    ST=SH=0;    //初始化端口

    while(1)
{


    buff(i,word);
    ST=1;  //锁存数据
    ST=0;
    switch(i)
    {
        case 0:A1=0; A2=0; A3=0;A4=0;move(k); break;
        case 1:A1=1; A2=0; A3=0;A4=0;move(k); break;
        case 2:A1=0; A2=1; A3=0;A4=0;move(k); break;
        case 3:A1=1; A2=1; A3=0;A4=0;move(k); break;  
        case 4:A1=0; A2=0; A3=1;A4=0;move(k); break;
        case 5:A1=1; A2=0; A3=1;A4=0;move(k); break;
        case 6:A1=0; A2=1; A3=1;A4=0;move(k); break;
        case 7:A1=1; A2=1; A3=1;A4=0;move(k); break;
        case 8:A1=0; A2=0; A3=0;A4=1;move(k); break;
        case 9:A1=1; A2=0; A3=0;A4=1;move(k); break;
        case 10:A1=0; A2=1; A3=0;A4=1;move(k); break;
        case 11:A1=1; A2=1; A3=0;A4=1;move(k); break;  
        case 12:A1=0; A2=0; A3=1;A4=1;move(k); break;
        case 13:A1=1; A2=0; A3=1;A4=1;move(k); break;
        case 14:A1=0; A2=1; A3=1;A4=1;move(k); break;
        case 15:A1=1; A2=1; A3=1;A4=1;move(k); break;
        default: break;
    } //动态刷新

    if(++i==16)
    {
       l++;
       i=0;
       if(l==3){l=0;
       k++;
       if(k==16){
           k=0;word++;}}
    }

    if(word==8)
        word=0;

}
}



友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
9条回答
天地不仁
1楼-- · 2019-07-16 12:35
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int

sbit DS=P2^0;  //串行时钟
sbit SH=P2^1;  //串行数据输入
sbit ST=P2^2;  //数据锁存
sbit A1=P1^0;
sbit A2=P1^1;
sbit A3=P1^2;
sbit A4=P1^3;  //138译码器



uchar code H[]=
{

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*--  文字:  电  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
      0x20,0x20,0x10,0x30,0x18,0x30,0x10,0x32,
      0x0B,0xFF,0x7C,0x30,0x18,0x30,0x18,0x78,
      0x18,0x78,0x18,0xCC,0x19,0x8E,0x1B,0x07,
      0x1C,0x02,0x36,0x00,0x63,0xFF,0x21,0xFE,


/*--  文字:  子  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0x3F,0xF0,0x00,0x20,0x00,0x40,0x00,0x80,0x01,0x00,0x01,0x00,0x01,0x04,
0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,

/*--  文字:  爱  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0xF8,0x3F,0x90,0x12,0x10,0x09,0x20,0x3F,0xFE,0x22,0x02,0x42,0x00,0x3F,0xFC,
0x04,0x00,0x07,0xF0,0x0C,0x20,0x0B,0x40,0x10,0xC0,0x63,0x30,0x8C,0x0E,0x30,0x04,

/*--  文字:  好  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x00,0x11,0xFC,0x10,0x08,0x10,0x10,0xFC,0x20,0x24,0x20,0x24,0x20,0x27,0xFE,
0x44,0x20,0x64,0x20,0x18,0x20,0x08,0x20,0x14,0x20,0x26,0x20,0x44,0xA0,0x80,0x40,

/******************************************************************************/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};


uchar BUFF[10];   //缓冲数组


void read(uchar dat)  
{
     uchar i;
     for(i=0;i<8;i++)
     {
         DS=(dat&0x80)?1:0;  //判断最高位,为真取1,为假取0
         SH=1;        //上升沿送数据
         SH=0;
         dat=dat<<1;  //左移取下一位
     }   
}//写入数据

void buff(uchar h,uchar word)
{
    uchar i;
    for(i=0;i<5;i++)
    {
        BUFF[2*i]=H[word+32*i+h*2];
        BUFF[2*i+1]=H[word+32*i+h*2+1];
    }
}//预先缓冲5个字

void move(uchar k)
{
    uchar i,temp,u8;
    if(k>=8)
    {
         k=k-8;
         u8=1;
    }
    else
         u8=0;
    for(i=0+u8;i<8+u8;i++)
    {
         temp=(BUFF[i]<<k)|(BUFF[i+1]>>(8-k));
         read(temp);
    }
}//向左移动

int main(void)
{ uchar i=0,k=0,l=0;uint word=0;
    ST=SH=0;    //初始化端口
   
    while(1)
{
   
   
   
    while(l<3){  
for(i=0;i<16;i++){
buff(i,word);
move(k);
if(i<8)P1=0xf0|i;
else P1=0xf8|(i-8);
ST=1;  //锁存数据
    ST=0; }
    /*switch(i)
    {
        case 0:A1=0; A2=0; A3=0;A4=0;move(k);i++; break;
        case 1:A1=1; A2=0; A3=0;A4=0;move(k);i++; break;
        case 2:A1=0; A2=1; A3=0;A4=0;move(k);i++; break;
        case 3:A1=1; A2=1; A3=0;A4=0;move(k);i++; break;  
        case 4:A1=0; A2=0; A3=1;A4=0;move(k);i++; break;
        case 5:A1=1; A2=0; A3=1;A4=0;move(k);i++; break;
        case 6:A1=0; A2=1; A3=1;A4=0;move(k);i++; break;
        case 7:A1=1; A2=1; A3=1;A4=0;move(k);i++; break;
        case 8:A1=0; A2=0; A3=0;A4=1;move(k);i++; break;
        case 9:A1=1; A2=0; A3=0;A4=1;move(k);i++; break;
        case 10:A1=0; A2=1; A3=0;A4=1;move(k);i++; break;
        case 11:A1=1; A2=1; A3=0;A4=1;move(k);i++; break;  
        case 12:A1=0; A2=0; A3=1;A4=1;move(k); i++;break;
        case 13:A1=1; A2=0; A3=1;A4=1;move(k);i++; break;
        case 14:A1=0; A2=1; A3=1;A4=1;move(k); i++;break;
        case 15:A1=1; A2=1; A3=1;A4=1;move(k);i=0;l++; break;
        default: break;
    } //动态刷新*/
l++;   
}
       if(l==3){l=0;
       k++;
       }
if(k==16){
           k=0;word+=32;}
    if(word==256)
        word=0;
   
}
}
天地不仁
2楼-- · 2019-07-16 14:37
 精彩回答 2  元偷偷看……
天地不仁
3楼-- · 2019-07-16 15:16
无意中找到的,

一周热门 更多>