您好,欢迎光临本网站![请登录][注册会员]  
文件名称: LED点阵矩阵时钟3216
  所属分类: 专业指导
  开发工具:
  文件大小: 1mb
  下载次数: 0
  上传时间: 2011-04-04
  提 供 者: vipzh******
 详细说明: 16*32点阵数字钟及汉字显示 附:点阵时间显示源程序 //===================================================================================// //*标题:16*32点阵数字钟显示程序 //*说明:时钟信号产生采用DS1302,列采用74HC595驱动(共4个),行驱动采用4-16线译码器74LS154 //*功能:通过动态扫描显示时钟,可显示时,分,秒,日期中的月和日 //*作者:HEY //*日期:2006-05-29 //*邮箱:billy3416@163.com //*备注:此是我刚接触单片机时的一个小制作 程序和电路设计上难免有不足之处 请谅解 //===================================================================================// #include #include #define uchar unsigned char //======================================== ===========================================// //用到的引脚及端口定义 //===================================================================================// sbit SERIALIN_0=P2^0; //定义P2.0为列向第1个74HC595的DATA输入 sbit SERIALIN_1=P2^1; //定义P2.1为列向第2个74HC595的DATA输入 sbit SERIALIN_2=P2^2; //定义P2.2为列向第2个74HC595的DATA输入 sbit SERIALIN_3=P2^3; //定义P2.3为列向第2个74HC595的DATA输入 sbit CLOCK_DATA=P1^0; //定义P1.0为DS1302的DATA端口 sbit CLOCK_RST=P1^1; //定义P1.1为DS1302的复位输出端口 sbit CLOCK_SCLK=P1^2; //定义P1.2为DS1302的时钟信号状态控制 sbit K0=P1^3; //K0为按键1,用来选择要调整时间的选项(时和分) sbit K1=P1^4; //K1为按键2,执行加1 sbit CLOCK=P2^4; //74HC595的移位时钟控制 sbit LATCH=P2^5; //74HC595的锁存输出时钟控制 void control(); //调整时间控制函数 void time(); uchar CLOCK_TIME[3]={0,0,0}; //定义时钟时间数据存储区,分别为(时,分,秒) uchar BUFFER[8]={0,0,0,0,0,0,0,0}; //显示缓冲区 uchar YEAR[3]={0,0,0}; //定义时钟年月日数据存储区 uchar temp[4]={0,0,0,0}; //定义74HC595的移位缓冲区 uchar FLASH_STOP; //显示小时和分钟之间的两点控制位 uchar sec_flash; //用单片机定时器模拟的一秒(用来控制小时和分中之间的两点) //===================================================================================// //定义0-9的点阵显示代码段 8*8 //===================================================================================// uchar code bmp[10][8]={ {0xe3,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xe3}, //0 {0xf7,0xc7,0xf7,0xf7,0xf7,0xf7,0xf7,0xc1}, //1 {0xe3,0xdd,0xdd,0xfd,0xfb,0xf7,0xef,0xc1}, //2 {0xe3,0xdd,0xfd,0xe3,0xfd,0xfd,0xdd,0xe3}, //3 {0xfb,0xf3,0xeb,0xdb,0xdb,0xc1,0xfb,0xf1}, //4 {0xc1,0xdf,0xdf,0xc3,0xfd,0xfd,0xdd,0xe3}, //5 {0xe3,0xdd,0xdf,0xc3,0xdd,0xdd,0xdd,0xe3}, //6 {0xc1,0xdd,0xfd,0xfb,0xf7,0xf7,0xf7,0xf7}, //7 {0xe3,0xdd,0xdd,0xe3,0xdd,0xdd,0xdd,0xe3}, //8 {0xe3,0xdd,0xdd,0xdd,0xe1,0xfd,0xdd,0xe3}, //9 }; //===================================================================================// //定义0-9的点阵显示代码段 8*8 与上面不同的是多了小时和分钟之间的两点 //===================================================================================// uchar code bmp_1[10][8]={ {0xe3,0xdd,0x5d,0xdd,0xdd,0x5d,0xdd,0xe3}, //:0 {0xf7,0xc7,0x77,0xf7,0xf7,0x77,0xf7,0xc1}, //:1 {0xe3,0xdd,0x5d,0xfd,0xfb,0x77,0xef,0xc1}, //:2 {0xe3,0xdd,0x7d,0xe3,0xfd,0x7d,0xdd,0xe3}, //:3 {0xfb,0xf3,0x6b,0xdb,0xdb,0x41,0xfb,0xf1}, //:4 {0xc1,0xdf,0x5f,0xc3,0xfd,0x7d,0xdd,0xe3}, //:4 {0xe3,0xdd,0x5f,0xc3,0xdd,0x5d,0xdd,0xe3}, //:5 {0xc1,0xdd,0x7d,0xfb,0xf7,0x77,0xf7,0xf7}, //:6 {0xe3,0xdd,0x5d,0xe3,0xdd,0x5d,0xdd,0xe3}, //:7 {0xe3,0xdd,0x5d,0xdd,0xe1,0x7d,0xdd,0xe3}, //:8 }; //===================================================================================// //定义0-9的点阵显示代码段 数码似的字模 8*8 显示数据前有一横杠将月和日格开 //===================================================================================// uchar code bmp_2[10][8]={ {0xff,0xff,0xf8,0xfa,0x8a,0xfa,0xf8,0xff}, //-0 {0xff,0xff,0xfe,0xfe,0x8e,0xfe,0xfe,0xff}, //-1 {0xff,0xff,0xf8,0xfe,0x88,0xfb,0xf8,0xff}, //-2 {0xff,0xff,0xf8,0xfe,0x88,0xfe,0xf8,0xff}, //-3 {0xff,0xff,0xfa,0xfa,0x88,0xfe,0xfe,0xff}, //-4 {0xff,0xff,0xf8,0xfb,0x88,0xfe,0xf8,0xff}, //-5 {0xff,0xff,0xf8,0xfb,0x88,0xfa,0xf8,0xff}, //-6 {0xff,0xff,0xf8,0xfe,0x8e,0xfe,0xfe,0xff}, //-7 {0xff,0xff,0xf8,0xfa,0x88,0xfa,0xf8,0xff}, //-8 {0xff,0xff,0xf8,0xfa,0x88,0xfe,0xf8,0xff}, //-9 }; //===================================================================================// //定义0-9的点阵显示代码段 模拟数码似的字模 8*8 //===================================================================================// uchar code bmp_3[10][8]={ {0xff,0xff,0x8f,0xaf,0xaf,0xaf,0x8f,0xff}, //0 {0xff,0xff,0xef,0xef,0xef,0xef,0xef,0xff}, //1 {0xff,0xff,0x8f,0xef,0x8f,0xbf,0x8f,0xff}, //2 {0xff,0xff,0x8f,0xef,0x8f,0xef,0x8f,0xff}, //3 {0xff,0xff,0xaf,0xaf,0x8f,0xef,0xef,0xff}, //4 {0xff,0xff,0x8f,0xbf,0x8f,0xef,0x8f,0xff}, //5 {0xff,0xff,0x8f,0xbf,0x8f,0xaf,0x8f,0xff}, //6 {0xff,0xff,0x8f,0xef,0xef,0xef,0xef,0xff}, //7 {0xff,0xff,0x8f,0xaf,0x8f,0xaf,0x8f,0xff}, //8 {0xff,0xff,0x8f,0xaf,0x8f,0xef,0x8f,0xff}, //9 }; //===================================================================================// //定义0-59模拟七段数码管显示 8*8 //===================================================================================// uchar code bmp_4[60][8]={ {0xff,0xff,0x88,0xaa,0xaa,0xaa,0x88,0xff}, //00 {0xff,0xff,0x8e,0xae,0xae,0xae,0x8e,0xff}, //01 {0xff,0xff,0x88,0xae,0xa8,0xab,0x88,0xff}, //02 {0xff,0xff,0x88,0xae,0xa8,0xae,0x88,0xff}, //03 {0xff,0xff,0x8a,0xaa,0xa8,0xae,0x8e,0xff}, //04 {0xff,0xff,0x88,0xab,0xa8,0xae,0x88,0xff}, //05 {0xff,0xff,0x88,0xab,0xa8,0xaa,0x88,0xff}, //06 {0xff,0xff,0x88,0xae,0xae,0xae,0x8e,0xff}, //07 {0xff,0xff,0x88,0xaa,0xa8,0xaa,0x88,0xff}, //08 {0xff,0xff,0x88,0xaa,0xa8,0xae,0x88,0xff}, //09 {0xff,0xff,0xe8,0xea,0xea,0xea,0xe8,0xff}, //10 {0xff,0xff,0xee,0xee,0xee,0xee,0xee,0xff}, //11 {0xff,0xff,0xe8,0xee,0xe8,0xeb,0xe8,0xff}, //12 {0xff,0xff,0xe8,0xee,0xe8,0xee,0xe8,0xff}, //13 {0xff,0xff,0xea,0xea,0xe8,0xee,0xee,0xff}, //14 {0xff,0xff,0xe8,0xeb,0xe8,0xee,0xe8,0xff}, //15 {0xff,0xff,0xe8,0xeb,0xe8,0xea,0xe8,0xff}, //16 {0xff,0xff,0xe8,0xee,0xee,0xee,0xee,0xff}, //17 {0xff,0xff,0xe8,0xea,0xe8,0xea,0xe8,0xff}, //18 {0xff,0xff,0xe8,0xea,0xe8,0xee,0xe8,0xff}, //19 {0xff,0xff,0x88,0xea,0x8a,0xba,0x88,0xff}, //20 {0xff,0xff,0x8e,0xee,0x8e,0xbe,0x8e,0xff}, //21 {0xff,0xff,0x88,0xee,0x88,0xbb,0x88,0xff}, //22 {0xff,0xff,0x88,0xee,0x88,0xbe,0x88,0xff}, //23 {0xff,0xff,0x8a,0xea,0x88,0xbe,0x8e,0xff}, //24 {0xff,0xff,0x88,0xeb,0x88,0xbe,0x88,0xff}, //25 {0xff,0xff,0x88,0xeb,0x88,0xba,0x88,0xff}, //26 {0xff,0xff,0x88,0xee,0x8e,0xbe,0x8e,0xff}, //27 {0xff,0xff,0x88,0xea,0x88,0xba,0x88,0xff}, //28 {0xff,0xff,0x88,0xea,0x88,0xbe,0x88,0xff}, //29 {0xff,0xff,0x88,0xea,0x8a,0xea,0x88,0xff}, //30 {0xff,0xff,0x8e,0xee,0x8e,0xee,0x8e,0xff}, //31 {0xff,0xff,0x88,0xee,0x88,0xeb,0x88,0xff}, //32 {0xff,0xff,0x88,0xee,0x88,0xee,0x88,0xff}, //33 {0xff,0xff,0x8a,0xea,0x88,0xee,0x8e,0xff}, //34 {0xff,0xff,0x88,0xeb,0x88,0xee,0x88,0xff}, //35 {0xff,0xff,0x88,0xeb,0x88,0xea,0x88,0xff}, //36 {0xff,0xff,0x88,0xee,0x8e,0xee,0x8e,0xff}, //37 {0xff,0xff,0x88,0xea,0x88,0xea,0x88,0xff}, //38 {0xff,0xff,0x88,0xea,0x88,0xee,0x88,0xff}, //39 {0xff,0xff,0xa8,0xaa,0x8a,0xea,0xe8,0xff}, //40 {0xff,0xff,0xae,0xae,0x8e,0xee,0xee,0xff}, //41 {0xff,0xff,0xa8,0xae,0x88,0xeb,0xe8,0xff}, //42 {0xff,0xff,0xa8,0xae,0x88,0xee,0xe8,0xff}, //43 {0xff,0xff,0xaa,0xaa,0x88,0xee,0xee,0xff}, //44 {0xff,0xff,0xa8,0xab,0x88,0xee,0xe8,0xff}, //45 {0xff,0xff,0xa8,0xab,0x88,0xea,0xe8,0xff}, //46 {0xff,0xff,0xa8,0xae,0x8e,0xee,0xee,0xff}, //47 {0xff,0xff,0xa8,0xaa,0x88,0xea,0xe8,0xff}, //48 {0xff,0xff,0xa8,0xaa,0x88,0xee,0xe8,0xff}, //49 {0xff,0xff,0x88,0xba,0x8a,0xea,0x88,0xff}, //50 {0xff,0xff,0x8e,0xbe,0x8e,0xee,0x8e,0xff}, //51 {0xff,0xff,0x88,0xbe,0x88,0xeb,0x88,0xff}, //52 {0xff,0xff,0x88,0xbe,0x88,0xee,0x88,0xff}, //53 {0xff,0xff,0x8a,0xba,0x88,0xee,0x8e,0xff}, //54 {0xff,0xff,0x88,0xbb,0x88,0xee,0x88,0xff}, //55 {0xff,0xff,0x88,0xbb,0x88,0xea,0x88,0xff}, //56 {0xff,0xff,0x88,0xbe,0x8e,0xee,0x8e,0xff}, //57 {0xff,0xff,0x88,0xba,0x88,0xea,0x88,0xff}, //58 {0xff,0xff,0x88,0xba,0x88,0xee,0x88,0xff}, //59 }; //===================================================================================// //名称:delay //说明:延时函数 //功能:根据需要取不同的值,实现不同的延时效果 //===================================================================================// void delay() { uchar n; for(n=0;n<=125;n++); } void delay2(uchar m) { uchar n; while(m--) { for(n=0;n<=200;n++); } } //===================================================================================// //名称:shift //说明:74HC595左移程序 //功能:实现74HC595的移位输入 //===================================================================================// void shift() { uchar j; for(j=0;j<8;j++) { temp[0]=temp[0]<<1; //将temp[0]左移1位 SERIALIN_0=CY; //进位输出到移位寄存器 temp[1]=temp[1]<<1; //将temp[1]左移1位后 SERIALIN_1=CY; //进位输出到移位寄存器 temp[2]=temp[2]<<1; //将temp[2]左移1位后 SERIALIN_2=CY; //进位输出到移位寄存器 temp[3]=temp[3]<<1; //将temp[0]左移1位后的进位输出到移位寄存器 SERIALIN_3=CY; //进位输出到移位寄存器 CLOCK=1; //移位时钟控制移位 CLOCK=0; } } //===================================================================================// //名称:display //说明:显示函数 //功能:将要显示的数据通过74HC595和74LS154用LED点阵显示出来 //实现方法:该16X32点阵为8块小点阵,显示时将上下分开,上面显示时间。下面显示日期和秒 //===================================================================================// void display(void) { uchar i,sec; sec=CLOCK_TIME[0]; BUFFER[0]=CLOCK_TIME[1]%10; //显示时钟分钟个位 BUFFER[1]=CLOCK_TIME[1]/10; //显示时钟分钟十位 BUFFER[2]=CLOCK_TIME[2]%10; //显示时钟小时个位 BUFFER[3]=CLOCK_TIME[2]/10; //显示时钟小时十位 BUFFER[4]=YEAR[1]; //显示月,从00-12 BUFFER[5]=YEAR[2]/10; //显示日十位 BUFFER[6]=YEAR[2]%10; //显示日个位 BUFFER[7]=CLOCK_TIME[0]; //显示秒从00-59 for(i=0;i<16;i++) //逐行扫描 { if(i<8) //上面的8行显示时间 { temp[0]=bmp[BUFFER[3]][i]; //取表显示时钟十位 temp[1]=bmp[BUFFER[2]][i]; //取表显示时钟个位 if(FLASH_STOP==0) //小时和分钟之间的两点闪标志位 { temp[2]=bmp_1[BUFFER[1]][i]; //标志位为0时,两点亮 } else { temp[2]=bmp[BUFFER[1]][i]; //相反不亮 } temp[3]=bmp[BUFFER[0]][i]; //取表显示分钟个位 } else { temp[0]=bmp_4[BUFFER[4]][i-8]; //通过取表显示月 temp[1]=bmp_2[BUFFER[5]][i-8]; //通过取表显示日 temp[2]=bmp_3[BUFFER[6]][i-8]; temp[3]=bmp_4[BUFFER[7]][i-8]; //通过取表显示秒 } shift(); //调用移位函数处理 LATCH=0;LATCH=1; //输出 P0=i; //逐行显示,扫描 delay(); //延时 P0=0xff; //显示完一行清显示 } } //===================================================================================// //单字节写子程序 RC0(SCLK),RC1(I/O),RC2(RST) //名称:inputdata //说明:先写地址,后写数据 //功能: 往DS1302写入时钟数据 //===================================================================================// void inputdata(unsigned char tmaddr,unsigned char tmdata) { uchar loop; CLOCK_DATA=0; //设置为输出; CLOCK_RST=0; CLOCK_SCLK=0; CLOCK_RST=1; for(loop=0;loop<8;loop++) //送地址 { tmaddr=tmaddr>>1; //右移一位 CLOCK_DATA=CY; //输出移位标志位 CLOCK_SCLK=1; CLOCK_SCLK=0; } for(loop=0;loop<8;loop++) //送数据 { tmdata=tmdata>>1; //右移一位 CLOCK_DATA=CY; //输出移位标志 CLOCK_SCLK=1; CLOCK_SCLK=0; } CLOCK_SCLK=1; CLOCK_RST=0; CLOCK_DATA=1; //设置为输出; } //===================================================================================// //单字节读子程序 RC0(SCLK),RC1(I/O),RC2(RST) //名称:outputdata //说明:读数据 //功能: 从DS1302读取1Byte数据 //===================================================================================// unsigned char outputdata(unsigned char tmaddr) { uchar loop; uchar tmdata=0; inputdata(0x8F,0x00); CLOCK_DATA=0; //设置为输 CLOCK_RST=0; CLOCK_SCLK=0; CLOCK_RST=1; for(loop=8;loop>0;loop--) //送地址 { tmaddr=tmaddr>>1; CLOCK_DATA=CY; CLOCK_SCLK=1; CLOCK_SCLK=0; } CLOCK_DATA=1; //设置为输入; CLOCK_DATA=1; CLOCK_SCLK=1; CLOCK_SCLK=0; for(loop=8;loop>0;loop--) // 读数据 { tmdata=tmdata>>1; if(CLOCK_DATA==1) tmdata=tmdata|0x80; CLOCK_SCLK=1; CLOCK_SCLK=0; } tmdata=tmdata<<1; //由于在开始读是已经是第二个时钟下降延所以要进行左移处理 if(CY==1) tmdata=tmdata|0x01; CLOCK_SCLK=1; CLOCK_RST=0; return(tmdata); } //===================================================================================// //函数:调整时间子程序 //名称:control //说明:调整时间控制 //功能: 通过两个按键调整时间,其中一个选择要调整的分钟或时钟,另一个加1功能 //===================================================================================// void control() { uchar min16,hour16; inputdata(0x80,0x80); //时钟停止运行 CLOCK_TIME[0]=0; //秒初始化位0 FLASH_STOP=0; //时钟分钟之间两点状态位为0 TR0=0; //开启T0定时器 while(1) { if(K1==0) //当K1按下时 { delay2(50); //延时 if(K1==0) //K1按下 { CLOCK_TIME[1]=CLOCK_TIME[1]+1; //分钟加1 if(CLOCK_TIME[1]==60) //当分钟加到60时初始化为0 CLOCK_TIME[1]=0; } } if(K0==0) //K0键再次按下,小时调整 { delay2(100); if(K0==0) { while(1) { if(K0==1) //K0键按下加1 { while(1) { if(K1==0) { delay2(50); if(K1==0) { CLOCK_TIME[2]=CLOCK_TIME[2]+1; //小时加1 if(CLOCK_TIME[2]==24) //当变成24时初始化为0 CLOCK_TIME[2]=0; } } if(K0==0) //当K0再次按下时返回 { delay2(100); if(K0==0) { while(1) { if(K0==1) //按下的键弹起时 { min16=CLOCK_TIME[1]/10*16+CLOCK_TIME[1]%10; //将所得的分钟数据转变成16进制数据 hour16=CLOCK_TIME[2]/10*16+CLOCK_TIME[2]%10; //将所得的小时数据转变成16进制数据 inputdata(0x84,hour16); //将调整后的小时数据写入DS1302 inputdata(0x82,min16); //将调整后的分钟数据写入DS1302 inputdata(0x80,0x00); //启动时钟 time(); //回到time函数 } } } } display(); //显示函数 } } } } } display(); //显示函数 } } //===================================================================================// //函数:T0中断服务子程序 //名称:time0 //说明:控制时钟和分钟之间的两点显示 //功能: 利用单片机内部定时器造成0.5秒时钟和分钟之间两点闪动 //===================================================================================// void time0(void) interrupt 1 using 1 //T0中断函数 { TH0=-10100/256; //填入计数器初值高位 TL0=-10100%256; //填入计数器初值低位 sec_flash=sec_flash+1; if(sec_flash==50) //0.5S到 { FLASH_STOP=0; } if(sec_flash==100) //1S到 { FLASH_STOP=1; sec_flash=0; } } //===================================================================================// //函数:时间控制函数 //说明:统一时钟显示于调整 //功能: //===================================================================================// void time() { uchar sec,min,hour,year,month,day; FLASH_STOP=1; EA=1;ET0=1; //开总中断源,开T0中断 TMOD=0x61; //T1方式2计数,T0方式1计时 TH0=-10000/256;TL0=-10000%256; //初始化计数器初值 ET0=1,TR0=1; //开中断 inputdata(0x8E,0x00); //控制命令,WP=0,写操作 inputdata(0x90,0x06); while(1) { K0=1; //K0=1 if(K0==0) { delay2(100); //延时 if(K0==0) //K0按下时 { while(1) { if(K0==1) { control(); //进入调时子程序 } } } } sec=outputdata(0x81); //读取秒 min=outputdata(0x83); //读取分 hour=outputdata(0x85); //读取时 year=outputdata(0x8d); //读取年 month=outputdata(0x89); //读取月 day=outputdata(0x87); //读取日 CLOCK_TIME[0]=sec/16*10+sec%16; //将读取到的16进制数转化为10进制 CLOCK_TIME[1]=min/16*10+min%16; //将读取到的16进制数转化为10进制 CLOCK_TIME[2]=hour/16*10+hour%16; //将读取到的16进制数转化为10进制 YEAR[0]=year/16*10+year%16; //将读取到的16进制数转化为10进制 YEAR[1]=month/16*10+month%16; YEAR[2]=day/16*10+day%16; display(); //调用显示子函数 } } //===================================================================================// //函数:主程序 //说明: //功能: //===================================================================================// void main() { time(); } 附:点阵汉字显示程序 //===================================================================================// //*标题:16*32点阵汉字显示程序 //*说明:采用89s51或52单片机,12M晶震,列采用74HC595驱动(共4个),行驱动采用4-16线译码器74LS154 //*功能:通过动态扫描显示汉字,并实现左移功能 //*作者:HEY //*日期:2006-06-01 //*邮箱:billy3416@163.com //*声明:以下源程序均通过keil调试与硬件实现均无问题 //===================================================================================// #include #include #define uchar unsigned char //===================================================================================// //用到的引脚及端口定义及全局变量 //===================================================================================// sbit SERIALIN_0=P2^0; //定义P2.0为列向第1个74HC595的DATA输入 sbit SERIALIN_1=P2^1; //定义P2.1为列向第1个74HC595的DATA输入 sbit SERIALIN_2=P2^2; //定义P2.2为列向第1个74HC595的DATA输入 sbit SERIALIN_3=P2^3; //定义P2.3为列向第1个74HC595的DATA输入 sbit CLOCK=P2^4; //74HC595的移位时钟控制 sbit LATCH=P2^5; //74HC595的锁存输出时钟控制 uchar temp[4]={0,0,0,0}; //用到的74HC595显示缓冲区变量 uchar disp[4][16]; //用到的显示缓冲区 //===================================================================================// //定义要显示的汉字代码段 16*16,分别是左上-左下-右上-右下 //===================================================================================// uchar code word[52][16]={ /*****点*****/ {0xfe,0xfe,0xfe,0xfe,0xfe,0xe0,0xef,0xef,0xef,0xe0,0xef,0xfe,0xd7,0xdb,0xbb,0xff}, {0xff,0xff,0x07,0xff,0xef,0x07,0xef,0xef,0xef,0x0f,0xef,0xef,0x77,0xbb,0xbb,0xff}, /*****阵*****/ {0xff,0x07,0x77,0x68,0x5e,0x6e,0x75,0x70,0x77,0x57,0x68,0x7f,0x7f,0x7f,0x7f,0x7f}, {0x7f,0x7f,0x7f,0x03,0xff,0xbf,0xbf,0x03,0xbf,0xbf,0x01,0xbf,0xbf,0xbf,0xbf,0xbf}, /*****显*****/ {0xff,0xe0,0xef,0xe0,0xef,0xe0,0xfb,0xfb,0xbb,0xdb,0xeb,0xeb,0xfb,0x00,0xff,0xff}, {0xff,0x0f,0xef,0x0f,0xef,0x0f,0xbf,0xbf,0xb7,0xb7,0xaf,0x9f,0xbf,0x01,0xff,0xff}, /*****示*****/ {0xff,0xe0,0xff,0xff,0xff,0x80,0xfe,0xfe,0xee,0xee,0xde,0xbe,0x7e,0xfe,0xfa,0xfd}, {0xff,0x07,0xff,0xff,0xff,0x01,0xff,0xff,0xdf,0xef,0xf7,0xf3,0xfb,0xff,0xff,0xff}, /*****由*****/ {0xfe,0xfe,0xfe,0xfe,0xc0,0xde,0xde,0xde,0xc0,0xde,0xde,0xde,0xde,0xc0,0xdf,0xff}, {0xff,0xff,0xff,0xff,0x07,0xf7,0xf7,0xf7,0x07,0xf7,0xf7,0xf7,0xf7,0x07,0xf7,0xff}, /*****信*****/ {0xf7,0xf3,0xe7,0xe8,0xcf,0xcc,0xaf,0x6c,0xef,0xec,0xed,0xed,0xed,0xec,0xed,0xff}, {0x7f,0x9f,0xbf,0x01,0xff,0x07,0xff,0x07,0xff,0x07,0xf7,0xf7,0xf7,0x07,0xf7,0xff}, /*****息*****/ {0xfe,0xfd,0xe0,0xef,0xe0,0xef,0xe0,0xef,0xe0,0xff,0xf6,0xd7,0xd7,0x97,0xf8,0xff}, {0xff,0xff,0x0f,0xef,0x0f,0xef,0x0f,0xef,0x0f,0xff,0xff,0x7b,0x6d,0xed,0x0f,0xff}, /*****工*****/ {0xff,0xc0,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0x00,0xff,0xff}, {0xff,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xff,0xff}, /*****程*****/ {0xf2,0x8e,0xee,0xee,0x02,0xee,0xcf,0xc4,0xab,0xaf,0x6c,0xef,0xef,0xef,0xe8,0xef}, {0x07,0xf7,0xf7,0xf7,0xf7,0x07,0xff,0x03,0xbf,0xbf,0x03,0xbf,0xbf,0xbf,0x01,0xff}, /*****学*****/ {0xfe,0xef,0xf3,0xf7,0x80,0xbf,0x70,0xff,0xff,0x80,0xff,0xff,0xff,0xff,0xfd,0xfe}, {0xf7,0x73,0x37,0x6f,0x01,0xfb,0x17,0xbf,0x7f,0x01,0x7f,0x7f,0x7f,0x7f,0x7f,0xff}, /*****院*****/ {0xff,0x07,0x70,0x6b,0x5f,0x5c,0x6f,0x77,0x70,0x56,0x6e,0x7e,0x7d,0x7d,0x7b,0x77}, {0x7f,0xbf,0x01,0xfb,0xff,0x07,0xff,0xff,0x01,0xdf,0xdf,0xdf,0xdd,0xdd,0xdd,0xe1}, {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff} }; //===================================================================================// //名称:delay //说明:延时函数 //功能:根据需要取不同的值,实现不同的延时效果 //===================================================================================// void delay() { uchar i; for(i=0;i<=100;i++); } //===================================================================================// //名称:shift //说明:74HC595左移程序 //功能:实现74HC595的移位输入 //===================================================================================// void shift() { uchar j; for(j=0;j<8;j++) { temp[0]=temp[0]<<1; //将temp[0]左移1位 SERIALIN_0=CY; //进位输出到移位寄存器 temp[1]=temp[1]<<1; //将temp[1]左移1位后 SERIALIN_1=CY; //进位输出到移位寄存器 temp[2]=temp[2]<<1; //将temp[2]左移1位后 SERIALIN_2=CY; //进位输出到移位寄存器 temp[3]=temp[3]<<1; //将temp[0]左移1位后的进位输出到移位寄存器 SERIALIN_3=CY; //进位输出到移位寄存器 CLOCK=1; //移位时钟控制移位 CLOCK=0; } } //===================================================================================// //名称:display—wor //说明:汉字显示子程序 //功能:实现汉字显示 //===================================================================================// void display_word() { uchar m,p; for(p=0;p<=20;p++) //一屏内容刷20次 { for(m=0;m<=15;m++) //从0-15行逐行扫描 { temp[0]=disp[0][m]; //将显示内容0放入缓冲区0 temp[1]=disp[1][m]; //将显示内容1放入缓冲区1 temp[2]=disp[2][m]; //将显示内容2放入缓冲区2 temp[3]=disp[3][m]; //将显示内容3放入缓冲区3 shift(); //左移 LATCH=0; //锁存输出 LATCH=1; P0=m; //显示当前行 delay(); //延时 P0=0xff; //显示完一行重新初始化防止重影 } } } //===================================================================================// //名称:main //说明:主函数 //功能:形成要显示的汉字代码实现各种功能显示,本例为左移显示 //===================================================================================// void main() { uchar i,j,m; while(1) { for(i=0;i<=23;i++) //一共显示11个字符 { for(j=0;j<8;j++) //左移0-7位实现左移 { for(m=0;m<=15;m++) //逐行左移 { disp[0][m]=(word[i][m]<>(8-j)); //将第i+1个8*8小块左移j位后的移出 disp[1][m]=(word[i+1][m]<>(8-j)); //值与第i个相或加在一起,形成左移效果 disp[2][m]=(word[i+2][m]<>(8-j)); // disp[3][m]=(word[i+3][m]<>(8-j)); // } display_word(); //调用显示 } } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: LED点阵 矩阵 时钟
 输入关键字,在本站1000多万海量源码库中尽情搜索: