硬件设计
8x16点阵方案如下
该方案支持左右滚动,可通过按键手动控制方向。
仿真图:
8x8点阵方案如下
该方案支持多种模式,例如0-9数字显示,跳动心等等
仿真图:
程序设计
程序1:
#include <reg51.h>#include <intrins.h>#include <stdio.h>#define uchar unsigned char#define uint unsigned intsbit RCK_Pin = P3^2;sbit k1 = P1^1;sbit k2 = P1^3;uchar flag=1;uchar code DSY_CONTENT_8x8_0[]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,0xE3,0x81,0x00,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xE7,0xE7,0xFF,0xEE,0xAD,0xAB,0x87,0xA3,0xAD,0xEE,0xFF,/*"天"*/0xEE,0xAD,0xAB,0x87,0xA3,0xAD,0xEE,0xFF,/*"天"*/0xFF,0xC0,0xB7,0xD3,0xD3,0xDF,0xC0,0xFF,/*"向"*/0xFF,0xFD,0xFD,0x81,0xED,0xED,0xFD,0xFF,/*"上"*/0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,};uchar code DSY_CONTENT_8x8_1[]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,0xE3,0x81,0x00,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xE7,0xE7,0xFF,0xEE,0xAD,0xAB,0x87,0xA3,0xAD,0xEE,0xFF,/*"天",0*/0xEE,0xAD,0xAB,0x87,0xA3,0xAD,0xEE,0xFF,/*"天",1*/0xFF,0xC0,0xDF,0xD3,0xD3,0xB7,0xC0,0xFF,/*"向",2*/0xFF,0xFD,0xED,0xED,0x81,0xFD,0xFD,0xFF,/*"上",3*/0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,};uchar Scan_BIT = 0x01;uchar Scan_BIT1 = 0x80;uchar Offset,Data_Index = 0;uchar Offset1,Data_Index1 = 0;void Delay(uint t){uchar i;while(t--) for(i=0;i<120;i++);}void T0_Led_Display_Control() interrupt 1{TH0 = (65536-1000)/256;TL0 = (65536-1000)%256;if(flag==0){Scan_BIT1=0x80;Data_Index1 = 0;Scan_BIT = _cror_(Scan_BIT,1);putchar(Scan_BIT);while(TI == 0);putchar( DSY_CONTENT_8x8_0[Offset + Data_Index + 8]);while (TI==0);putchar( DSY_CONTENT_8x8_0[Offset + Data_Index ]);while(TI == 0);Data_Index = (Data_Index + 1) % 8;RCK_Pin = 1;RCK_Pin = 0;}if(flag==1){Scan_BIT=0x01;Data_Index = 0;Scan_BIT1 = _crol_(Scan_BIT1,1);putchar(Scan_BIT1);while(TI == 0);putchar( DSY_CONTENT_8x8_1[Offset1 + Data_Index1]);while (TI==0);putchar( DSY_CONTENT_8x8_1[Offset1 + Data_Index1 + 8 ]);while(TI == 0);Data_Index1 = (Data_Index1 + 1) % 8;RCK_Pin = 1;RCK_Pin = 0;}}void main(){uchar i;TMOD = 0x01;TH0 = (65536-1000) / 256;TL0 = (65536-1000) % 256;IE = 0x82;TCON =0x00;TI = 1;while(1){for(i=0;i<64;i++){
程序2:
#include <reg52.h>sbit ADDR0 = P1^0;sbit ADDR1 = P1^1;sbit ADDR2 = P1^2;sbit ADDR3 = P1^3;sbit KEY = P3^5;unsigned int cnt,m,stage,sec=1000;unsigned char code image[][8] = {{0xFF,0xE7,0xDB,0xDB,0xDB,0xDB,0xE7,0xFF},//0{0xFF,0xE7,0xEF,0xEF,0xEF,0xEF,0xC3,0xFF},//1{0xFF,0xE3,0xDF,0xDF,0xE7,0xFB,0xC3,0xFF},//2{0xE3,0xDF,0xDF,0xE7,0xDF,0xDF,0xE3,0xFF},//3{0xFF,0xEF,0xE7,0xEB,0xC3,0xEF,0xEF,0xFF}, //4{0xFB,0xC3,0xFB,0xE3,0xDF,0xDF,0xE3,0xFF},//5{0xE7,0xFB,0xFB,0xE3,0xDB,0xDB,0xE7,0xFF}, //6{0xFF,0xC3,0xDF,0xDF,0xDF,0xDF,0xDF,0xFF}, //7{0xE7,0xDB,0xDB,0xE7,0xDB,0xDB,0xE7,0xFF}, //8{0xE7,0xDB,0xDB,0xC7,0xDF,0xDF,0xE7,0xFF}//9};unsigned char code image1[][8] = {//心跳{0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7}, //大心{0xFF,0xFF,0xDB,0x81,0x81,0xC3,0xE7,0xFF}, //中心{0xFF,0xFF,0xFF,0xDB,0xC3,0xE7,0xFF,0xFF}, //小心};unsigned char code image3[][8] = {//小坦克{0xFE,0xFF,0xE3,0xE3,0xF7,0xFF,0xFF,0xFF},{0xFE,0xFF,0xFF,0xE3,0xE3,0xF7,0xFF,0xFF},{0xFE,0xFF,0xFF,0xFF,0xE3,0xE3,0xF7,0xFF},{0xFE,0xFF,0xFF,0xFF,0xF3,0xE3,0xF3,0xFF},{0xFE,0xFF,0xFF,0xFF,0xE7,0xC7,0xE7,0xFF},{0xFE,0xFF,0xFF,0xFF,0xCF,0x8F,0xCF,0xFF},{0xFE,0xFF,0xFF,0xFF,0xDF,0x8F,0x8F,0xFF},{0xFE,0xFF,0xFF,0xDF,0x8F,0x8F,0xFF,0xFF},{0xFE,0xFF,0xDF,0x8F,0x8F,0xFF,0xFF,0xFF},{0xFE,0xDF,0x8F,0x8F,0xFF,0xFF,0xFF,0xFF},};unsigned char code image2[] = {//0-->9平移0xFF,0xE7,0xDB,0x5A,0x5A,0xDB,0xE7,0xFF,0xFF,0xE7,0xEF,0x6E,0x6E,0xEF,0xC3,0xFF,0xFF,0xE3,0xDF,0x5E,0x66,0xFB,0xC3,0xFF,0xE3,0xDF,0xDF,0x66,0x5E,0xDF,0xE3,0xFF,0xFF,0xEF,0xE7,0x6A,0x42,0xEF,0xEF,0xFF,0xFB,0xC3,0xFB,0x62,0x5E,0xDF,0xE3,0xFF,0xE7,0xFB,0xFB,0x62,0x5A,0xDB,0xE7,0xFF,0xFF,0xC3,0xDF,0x5E,0x5E,0xDF,0xDF,0xFF,0xE7,0xDB,0xDB,0x66,0x5A,0xDB,0xE7,0xFF,0xE7,0xDB,0xDB,0x46,0x5E,0xDF,0xE7,0xFF,};void Delay10ms(){unsigned char i, j;i = 20;j = 113;do{while (--j);} while (--i);}void main(){EA = 1; //使能总中断ADDR3 = 0;TMOD = 0x01; //设置T0为模式1TH0 = 0xFC; //为T0赋初值0xFC67,定时1msTL0 = 0x67;ET0 = 1;//使能T0中断TR0 = 1;//启动T0while (1){if(stage>3)stage=0;if(KEY==0) {Delay10ms();if(KEY==1)stage++;}if(cnt >= sec){cnt = 0;m++;}}}/* 定时器0中断服务函数 */void InterruptTimer0() interrupt 1{static unsigned char i = 0; //动态扫描的索引static unsigned char tmr = 0; //250ms软件定时器static unsigned char index = 0; //图片刷新索引TH0 = 0xFC; //重新加载初值TL0 = 0x67;P0 = 0xFF; //显示消隐cnt++;/***********************模式一:数字闪出***********************************/if(stage==0){sec = 1000;if(m>=10)m=0;switch (i){case 0: ADDR2=0; ADDR1=0; ADDR0=0; i++; P0=image[m][0]; break;case 1: ADDR2=0; ADDR1=0; ADDR0=1; i++; P0=image[m][1]; break;case 2: ADDR2=0; ADDR1=1; ADDR0=0; i++; P0=image[m][2]; break;case 3: ADDR2=0; ADDR1=1; ADDR0=1; i++; P0=image[m][3]; break;case 4: ADDR2=1; ADDR1=0; ADDR0=0; i++; P0=image[m][4]; break;case 5: ADDR2=1; ADDR1=0; ADDR0=1; i++; P0=image[m][5]; break;case 6: ADDR2=1; ADDR1=1; ADDR0=0; i++; P0=image[m][6]; break;case 7: ADDR2=1; ADDR1=1; ADDR0=1; i=0; P0=image[m][7]; break;default: break;}}/**********************模式二:动态爱心************************************/else if(stage==1){sec = 150;if(m>=3)m=0;switch (i){case 0: ADDR2=0; ADDR1=0; ADDR0=0; i++; P0=image1[m][0]; break;case 1: ADDR2=0; ADDR1=0; ADDR0=1; i++; P0=image1[m][1]; break;case 2: ADDR2=0; ADDR1=1; ADDR0=0; i++; P0=image1[m][2]; break;case 3: ADDR2=0; ADDR1=1; ADDR0=1; i++; P0=image1[m][3]; break;case 4: ADDR2=1; ADDR1=0; ADDR0=0; i++; P0=image1[m][4]; break;case 5: ADDR2=1; ADDR1=0; ADDR0=1; i++; P0=image1[m][5]; break;case 6: ADDR2=1; ADDR1=1; ADDR0=0; i++; P0=image1[m][6]; break;case 7: ADDR2=1; ADDR1=1; ADDR0=1; i=0; P0=image1[m][7]; break;default: break;}}/**********************模式三:坦克走动**************************************/else if(stage==2){sec = 800;if(m>=10)m=0;switch (i){case 0: ADDR2=0; ADDR1=0; ADDR0=0; i++; P0=image3[m][0]; break;case 1: ADDR2=0; ADDR1=0; ADDR0=1; i++; P0=image3[m][1]; break;case 2: ADDR2=0; ADDR1=1; ADDR0=0; i++; P0=image3[m][2]; break;case 3: ADDR2=0; ADDR1=1; ADDR0=1; i++; P0=image3[m][3]; break;case 4: ADDR2=1; ADDR1=0; ADDR0=0; i++; P0=image3[m][4]; break;case 5: ADDR2=1; ADDR1=0; ADDR0=1; i++; P0=image3[m][5]; break;case 6: ADDR2=1; ADDR1=1; ADDR0=0; i++; P0=image3[m][6]; break;case 7: ADDR2=1; ADDR1=1; ADDR0=1; i=0; P0=image3[m][7]; break;default: break;}}/**********************模式四:数字平移****************************************/else if(stage==3){switch (i){
附:http://www.jh-/archives/7541