这是我前段时间制作的16*16点阵屏。还有很多实用实例,总之很实用。
现上传给大家,共同分享。
各种花样显示效果的源码(交替显示,拉幕式方式显示,显示数字,向上滚动显示,欢迎光临等等):
满足先悦电子接口方法
//IO配置
sbit D_port = P1^7;
sbit C_port = P1^6;
sbit B_port = P1^5;
sbit A_port = P1^4;
sbit EN_port = P1^3;
sbit S_IN_port = P1^2;
sbit RCK_port = P1^1;
sbit SRCK_port = P1^0;
如果程序里面有说明使用的晶体频率跟单片机芯片型号的,请按照要求使用,如果没有要求的,可以使用任何51内核的单片机。
因为AT89S51,AT89S52,AT89C51,AT89C52的RAM只有128,里面的程序有很多个是要求使用256以上RAM的,因此建议你使用STC
系列的单片机。
仅供焊接完进行点阵测试用。
16*16电子的电路原理图:
单片机源程序如下:
- /*字取模方法请参考本目录图片说明*/
- /*头文件*/
- #include <reg52.h>
- #include <intrins.h>
- #define uint unsigned int
- #define uchar unsigned char
- #define _Nop() _nop_()
- /*端口定义*/
- sbit D_port = P1^7;
- sbit C_port = P1^6;
- sbit B_port = P1^5;
- sbit A_port = P1^4;
- sbit EN_port = P1^3;
- sbit S_IN_port = P1^2;
- sbit RCK_port = P1^1;
- sbit SRCK_port = P1^0;
- uchar code table[]={
- 0xFF,0xFC,0xFF,0xFC,0x80,0xFC,0x9F,0x80,0x1F,0x9E,0x49,0xCE,0x03,0xF9,0x87,0xF9,
- 0xE7,0xF9,0xC3,0xF0,0x93,0xF0,0x19,0xE6,0x7C,0xE6,0x3F,0xCF,0x9F,0x9F,0xCF,0x3F,/*"欢",0*/
- 0xFF,0xFF,0xF3,0xFC,0x27,0x82,0x27,0x93,0x3F,0x93,0x3F,0x93,0x20,0x93,0x27,0x93,
- 0x27,0x93,0x27,0x80,0x27,0xC2,0x27,0xF3,0xE7,0xF3,0xC3,0xF3,0x19,0x00,0xFF,0xFF,/*"迎",0*/
- 0x7F,0xFE,0x73,0xCE,0x67,0xCE,0x4F,0xE6,0x4F,0xF2,0x7F,0xFE,0x00,0x00,0x9F,0xF9,
- 0x9F,0xF9,0x9F,0xF9,0x9F,0xF9,0xCF,0x39,0xCF,0x39,0xE7,0x39,0xF3,0x03,0xF8,0xFF,/*"光",1*/
- 0xCF,0xFC,0xCF,0xFC,0xCF,0xFC,0x49,0x00,0x49,0xF8,0x09,0xF3,0x89,0xF3,0xC9,0xFF,
- 0x49,0x80,0x49,0x92,0x49,0x92,0x49,0x92,0x49,0x92,0x4F,0x80,0x4F,0x9E,0xCF,0xFF,/*"临",2*/
-
- };
- /*-------------------------------------------------------
- 点阵LED第几行显示数据
- 其中daH为数据高8位,daL为数据低8位,han为第几行显示
- --------------------------------------------------------*/
- void HC595_Data_Send(uchar daH,daL,han)
- {
- uchar i;
- RCK_port = 0; /*HC595锁定输出,避免数据传输过程中,屏数据变化从而显示闪烁*/
- SRCK_port = 0;
- for(i=0;i<8;i++){
- if((daH&0x80)!=0) S_IN_port = 1;
- else S_IN_port = 0;
- SRCK_port = 1;
- SRCK_port = 0;
- daH <<= 1;
- }
- for(i=0;i<8;i++){
- if((daL&0x80)!=0) S_IN_port = 1;
- else S_IN_port = 0;
- SRCK_port = 1;
- SRCK_port = 0;
- daL <<= 1;
- }
- EN_port = 1; /*关屏显示,原理为使HC138输出全为1,从而三极管截止,点阵不显示*/
- switch (han){
- case 0:
- A_port = 0; B_port = 0; C_port = 0; D_port = 0;
- break;
- case 1:
- A_port = 1; B_port = 0; C_port = 0; D_port = 0;
- break;
- case 2:
- A_port = 0; B_port = 1; C_port = 0; D_port = 0;
- break;
- case 3:
- A_port = 1; B_port = 1; C_port = 0; D_port = 0;
- break;
- case 4:
- A_port = 0; B_port = 0; C_port = 1; D_port = 0;
- break;
- case 5:
- A_port = 1; B_port = 0; C_port = 1; D_port = 0;
- break;
- case 6:
- A_port = 0; B_port = 1; C_port = 1; D_port = 0;
- break;
- case 7:
- A_port = 1; B_port = 1; C_port = 1; D_port = 0;
- break;
- case 8:
- A_port = 0; B_port = 0; C_port = 0; D_port = 1;
- break;
- case 9:
- A_port = 1; B_port = 0; C_port = 0; D_port = 1;
- break;
- case 10:
- A_port = 0; B_port = 1; C_port = 0; D_port = 1;
- break;
- case 11:
- A_port = 1; B_port = 1; C_port = 0; D_port = 1;
- break;
- case 12:
- A_port = 0; B_port = 0; C_port = 1; D_port = 1;
- break;
- case 13:
- A_port = 1; B_port = 0; C_port = 1; D_port = 1;
- break;
- case 14:
- A_port = 0; B_port = 1; C_port = 1; D_port = 1;
- break;
- case 15:
- A_port = 1; B_port = 1; C_port = 1; D_port = 1;
- break;
- }
- RCK_port = 1; /*允许HC595数据输出到Q1-Q8端口*/
- EN_port = 0; /*HC138输出有效,打开显示*/
- RCK_port = 0; /*锁定HC595数据输出*/
- }
- void delay_1ms(uchar x)
- {
- uchar j;
- while(x--){
- for(j=0;j<15;j++)
- {;}
- }
- }
- void main()
- {
- uint i;
- uchar j=0; /*读取对应的第几行数据*/
- uchar k=0; /*读取对应的第几个字数据*/
- while (1){
- for(i=0;i<3000;i++){
- HC595_Data_Send(table[(k*16+j)*2+1],table[(k*16+j)*2],j);
- j++; /*行加1*/
- if(j==16) j=0;
- delay_1ms(1);
- }
- k++; /*字加1*/
- if(k==4) k=0;
- }
- }
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
16x16点阵套件资料包.rar
(15.84 MB, 下载次数: 128)
|