51微控制器 16X16點陣迴圈滾動顯示漢字(基於proteus)

TEER發表於2018-09-16

原創文章,轉載註明地址作者,作者TEER。

一、效果展示

二、所用材料

1.16X16點陣

Proteus並不提供16X16的點陣,只能我們自己通過4個8X8的組裝為16X16的點陣。

由此可知8*8變成16*16

列需要這樣連線:

行需要這樣連線:

再把四個放在一起即可:

2.74hc595

詳細介紹見我上一篇文章

https://blog.csdn.net/qq_41639829/article/details/82151706

這裡需要用到級聯,也不算太難,就相當於原來是輸入8個數,這需要輸入16個,然後再輸出,前八個輸入的就被自動擠到級聯的下一個595中了!

3.stc89c52

三、原理

1.靜態顯示

同8位的靜態顯示一樣,只不過是從8個變成16個而已。

詳見上一篇文章。

https://mp.csdn.net/postedit/82222753

2.動態顯示

同8位的動態顯示一樣,只不過是從8個變成16個而已。

詳見上一篇文章。

https://mp.csdn.net/postedit/82222753

四、proteus接線方式

五、程式碼展示

#include <reg51.h>
#include<intrins.h>

/*  資料端介面定義 */
sbit  LSH = P2^0;     //列數時鐘
sbit  LDS = P2^1;     //輸入
sbit  LST = P2^2;     //列暫存器

sbit  HSH = P2^3;     //行數時鐘
sbit  HDS = P2^4;     //輸入
sbit  HST = P2^5;     //行暫存器時鐘

unsigned int sel[17]={0x7fff,0xbfff,0xdfff,0xefff,0xf7ff,0xfbff,0xfdff,0xfeff,
											0xff7f,0xffbf,0xffdf,0xffef,0xfff7,0xfffb,0xfffd,0xfffe,
	                    0xffff,
										 };

char code hanzi[170] =
{
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,
0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x0A,0x01,0x02,0x01,0x02,0x00,0xFE,//電
0x00,0x00,
0x00,0x00,0x7F,0xF8,0x00,0x10,0x00,0x20,0x00,0x40,0x01,0x80,0x01,0x00,0xFF,0xFE,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,//子
0x00,0x00,
0x01,0x00,0x01,0x00,0x7F,0xFC,0x01,0x00,0x1F,0xF0,0x00,0x00,0x7F,0xFE,0x40,0x02,
0x9F,0xF4,0x00,0x00,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x08,0x20,0x04,0x40,0xFF,0xFE,//壹
0x00,0x00,
0x20,0x80,0x10,0x80,0x00,0x9C,0x47,0xE0,0x20,0x80,0x08,0x84,0x10,0x84,0x60,0x7C,
0x21,0x00,0x01,0x00,0xFF,0xFE,0x05,0x40,0x09,0x20,0x31,0x18,0xC1,0x06,0x01,0x00,//柒
0x00,0x00,
0x01,0x00,0x00,0x80,0x3F,0xFE,0x20,0x80,0x2F,0xF8,0x20,0x88,0x3F,0xFE,0x20,0x88,
0x2F,0xF8,0x28,0x80,0x24,0xC4,0x22,0xA8,0x44,0x90,0x48,0x88,0x92,0x86,0x01,0x00,//康
0x00,0x00,
};



void send_data_H(unsigned int dat);  /*  傳送行資料端資料函式  */
void send_data_L(unsigned int dat);  /*  傳送列選通端資料函式  */
void display(int a);                 //每一次顯示什麼東西
void delay(unsigned int m);


void main()
{
  unsigned int j=0,num;
	while(1)
	{
		num=6;
		while(num--)
		{
				display(j);
			  delay(10);
	  }
		j=j+2;
		//if(j>150)
			//j=0;
	}
}
	  //unsigned int a,b;	
		//a=sel[i]%256;//後八位
	  //b=sel[i]/256;//前八位
    //send_data_H(b);
void send_data_L(unsigned int dat)
{
    unsigned char i;
    
    for(i=0;i<8;i++)
    {
        LSH = 0;
        LDS = dat&0x80;       //temp<<=1;
        dat = dat<<1;               //ds = CY;
        LSH = 1;
    }
		LST = 0;
    _nop_();
    _nop_();
    LST = 1;
}

void send_data_H(unsigned int dat)
{
    int i; 
    for(i=0;i<16;i++)
    {
			  
        HSH = 0;
        HDS = dat&0x8000;
        dat =dat<<1;
        HSH = 1;
    }	
		HST = 0;
    _nop_();
    HST = 1;
}
void delay(unsigned int m)
{
    unsigned char i;
    for(;m>0;m--)
    {
        for(i=0;i<124;i++)
			{}
    }
}

void display( int a)
{
    unsigned char i;
	  unsigned int x;
    for(i=0;i<16;i++)
    {
        send_data_H(sel[i]);
			  x=a+2*i;//展示第幾個字元
			  if(a+2*i>168)
					x=(a+2*i)%170;
			  send_data_L(hanzi[x]);
			  send_data_L(hanzi[x+1]);
			  delay(1);	  
    }
}

相關文章