芯片采用STC89C52,74HC154以及74HC595芯片作为列行驱动电路。主要有五种功能,上移,下移,左移,顺序,特殊。还设有拉幕功能。
能看懂代码的可自行修改汉字及拉幕特效。
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include<reg52.h>
- #define BLKN 4
- #define TOTAL 8
- #define TOTAL1 8
- sbit G=P1^7;
- sbit CLK=P1^6;
- sbit SCLR=P1^5;
- sbit S1=P2^0;
- sbit S2=P2^1;
- sbit S3=P2^2;
- sbit S4=P2^3;
- sbit S5=P2^4;
- unsigned char keyval;
- unsigned char idata dispram[(BLKN/2)*32]={0};
- /*****************???*********************/
- unsigned char code Bmp[][32]= //上移,不卑不亢不慌不忙
- {
- 0x00,0x04,0xFF,0xFE,0x00,0x80,0x00,0x80,0x01,0x00,0x01,0x00,0x03,0x40,0x05,0x20,
- 0x09,0x18,0x11,0x0C,0x21,0x04,0x41,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
- 0x01,0x00,0x02,0x10,0x1F,0xF8,0x11,0x10,0x11,0x10,0x1F,0xF0,0x11,0x10,0x12,0x10,
- 0x1F,0xF0,0x05,0x00,0x09,0x04,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
- 0x00,0x04,0xFF,0xFE,0x00,0x80,0x00,0x80,0x01,0x00,0x01,0x00,0x03,0x40,0x05,0x20,
- 0x09,0x18,0x11,0x0C,0x21,0x04,0x41,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
- 0x02,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x00,0x00,0x00,0x20,0x0F,0xF0,0x08,0x20,
- 0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x10,0x22,0x10,0x22,0x20,0x1E,0x40,0x00,
- 0x00,0x04,0xFF,0xFE,0x00,0x80,0x00,0x80,0x01,0x00,0x01,0x00,0x03,0x40,0x05,0x20,
- 0x09,0x18,0x11,0x0C,0x21,0x04,0x41,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
- 0x11,0x10,0x11,0x14,0x1F,0xFE,0x11,0x10,0x58,0x44,0x57,0xFE,0x52,0x00,0x92,0x08,
- 0x13,0xFC,0x10,0x00,0x12,0x48,0x12,0x48,0x12,0x48,0x12,0x4A,0x14,0x4A,0x18,0x46,
- 0x00,0x04,0xFF,0xFE,0x00,0x80,0x00,0x80,0x01,0x00,0x01,0x00,0x03,0x40,0x05,0x20,
- 0x09,0x18,0x11,0x0C,0x21,0x04,0x41,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
- 0x10,0x80,0x10,0x60,0x10,0x20,0x10,0x04,0x5F,0xFE,0x5A,0x00,0x52,0x00,0x92,0x00,
- 0x12,0x00,0x12,0x00,0x12,0x00,0x12,0x00,0x12,0x08,0x13,0xFC,0x10,0x00,0x10,0x00,
- };
- unsigned char code Bmp1[][32]= //静态,通大
- {
- 0x03,0xF8,0x40,0x10,0x30,0xA0,0x10,0x48,0x03,0xFC,0x02,0x48,0xF2,0x48,0x13,0xF8,
- 0x12,0x48,0x12,0x48,0x13,0xF8,0x12,0x48,0x12,0x68,0x2A,0x50,0x44,0x06,0x03,0xFC,
- 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x01,0x00,0x02,0x80,
- 0x02,0x80,0x02,0x40,0x04,0x40,0x04,0x20,0x08,0x10,0x10,0x0E,0x60,0x04,0x00,0x00,
- };
- unsigned char code Bmp2[][32]= //左移,人要学会知足常乐
- {
- 0x00,0x08,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x08,0x7F,0xFC,
- 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x00,0x00,
- 0x00,0x00,0x17,0xFE,0xFC,0x02,0x28,0xA4,0x21,0x18,0x22,0x08,0xF8,0x40,0x20,0x44,
- 0x2F,0xFE,0x20,0x40,0x20,0xE0,0x39,0x50,0xE2,0x48,0x44,0x4E,0x08,0x44,0x00,0x40,
- 0x01,0x00,0x01,0x08,0x7F,0xFC,0x01,0x10,0x1F,0xF8,0x10,0x10,0x1F,0xF0,0x10,0x10,
- 0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x14,0xFF,0xFE,0x08,0x20,0x10,0x18,0x20,0x08,
- 0x08,0x20,0x08,0x20,0x48,0x24,0x49,0xFE,0x49,0x24,0x49,0x24,0x49,0x24,0x49,0x24,
- 0x49,0x24,0x49,0x24,0x49,0x24,0x09,0x24,0x11,0x34,0x11,0x28,0x20,0x20,0x40,0x20,
- 0x00,0x08,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x08,0x7F,0xFC,
- 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x00,0x00,
- 0x00,0x00,0x17,0xFE,0xFC,0x02,0x28,0xA4,0x21,0x18,0x22,0x08,0xF8,0x40,0x20,0x44,
- 0x2F,0xFE,0x20,0x40,0x20,0xE0,0x39,0x50,0xE2,0x48,0x44,0x4E,0x08,0x44,0x00,0x40,
- 0x01,0x00,0x01,0x08,0x7F,0xFC,0x01,0x10,0x1F,0xF8,0x10,0x10,0x1F,0xF0,0x10,0x10,
- 0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x14,0xFF,0xFE,0x08,0x20,0x10,0x18,0x20,0x08,
- 0x08,0x20,0x08,0x20,0x48,0x24,0x49,0xFE,0x49,0x24,0x49,0x24,0x49,0x24,0x49,0x24,
- 0x49,0x24,0x49,0x24,0x49,0x24,0x09,0x24,0x11,0x34,0x11,0x28,0x20,0x20,0x40,0x20,
- };
- unsigned char code Bmp3[][32]= //特殊,再见了
- {
- 0x00,0x08,0x7F,0xFC,0x01,0x00,0x01,0x10,0x1F,0xF8,0x11,0x10,0x11,0x10,0x1F,0xF0,
- 0x11,0x10,0x11,0x14,0xFF,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x50,0x10,0x20,
- 0x00,0x10,0x1F,0xF8,0x10,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,
- 0x11,0x10,0x12,0x10,0x12,0x90,0x04,0x80,0x04,0x82,0x08,0x82,0x30,0x7E,0xC0,0x00,
- 0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,
- 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,
- 0x00,0x00,0xF8,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
- unsigned char code Bmp4[][32]= //下移,人要学会知足常乐
- {
- 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x02,0x80,
- 0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x08,0x20,0x10,0x10,0x20,0x0E,0x40,0x04,
- 0x00,0x08,0x7F,0xFC,0x04,0x40,0x3F,0xF8,0x24,0x48,0x24,0x48,0x3F,0xF8,0x02,0x00,
- 0x02,0x04,0xFF,0xFE,0x04,0x20,0x08,0x20,0x06,0x40,0x01,0x80,0x06,0x60,0x38,0x10,
- 0x22,0x08,0x11,0x08,0x11,0x10,0x00,0x20,0x7F,0xFE,0x40,0x02,0x80,0x04,0x1F,0xE0,
- 0x00,0x40,0x01,0x84,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,
- 0x01,0x00,0x01,0x00,0x02,0x80,0x04,0x40,0x08,0x20,0x10,0x10,0x2F,0xEE,0xC0,0x04,
- 0x00,0x10,0x3F,0xF8,0x02,0x00,0x02,0x00,0x04,0x40,0x08,0x20,0x1F,0xF0,0x00,0x10,
- 0x20,0x00,0x20,0x00,0x22,0x04,0x3F,0x7E,0x28,0x44,0x48,0x44,0x88,0x44,0x09,0x44,
- 0xFF,0xC4,0x08,0x44,0x08,0x44,0x14,0x44,0x12,0x44,0x22,0x7C,0x40,0x44,0x80,0x00,
- 0x00,0x10,0x1F,0xF8,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x11,0x10,
- 0x01,0x00,0x11,0x10,0x11,0xF8,0x11,0x00,0x11,0x00,0x29,0x06,0x47,0xFC,0x80,0x00,
- 0x01,0x00,0x11,0x10,0x09,0x20,0x7F,0xFE,0x40,0x02,0x8F,0xE4,0x08,0x20,0x0F,0xE0,
- 0x01,0x10,0x1F,0xF8,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x50,0x01,0x20,0x01,0x00,
- 0x00,0x20,0x00,0xF0,0x1F,0x00,0x10,0x00,0x11,0x00,0x11,0x00,0x21,0x04,0x7F,0xFE,
- 0x01,0x00,0x01,0x00,0x09,0x20,0x09,0x10,0x11,0x08,0x21,0x0C,0x45,0x04,0x02,0x00,
- };
- /*************延时1ms**************/
- void delay(unsigned int dt)
- {
- register unsigned char bt;
- for(;dt;dt--)
- for(bt=0;bt<250;bt++);
- }
- /**********按键去抖********/
- void delay20ms(void)
- {
- unsigned char i,j;
- for(i=0;i<100;i++)
- for(j=0;j<60;j++);
- }
- /***********上移****************/
- void fun1()
- {
- register unsigned char i,j,k,q;
- for(i=0;i<32;i++)
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=0x00;
- }
- if(i%2)delay(1);
- }
- for(i=0;i<TOTAL*2/BLKN;i++)
- {
- for (j=0;j<16;j++)
- {
- for(k=0;k<15;k++)
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[k*2+q*32]=dispram[(k+1)*2+q*32];
- dispram[k*2+1+q*32]=dispram[(k+1)*2+1+q*32];
- }
- }
- for(q=0;q<BLKN/2;q++)
- {
- dispram[30+q*32]=Bmp[q+i*BLKN/2][j*2];
- dispram[31+q*32]=Bmp[q+i*BLKN/2][j*2+1];
- }
- delay(60);
- }
- delay(250);
- }
- for(i=0;i<32;i++) //下联
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=0x00;
- }
- if(i%2)delay(60);
- }
- delay(250);
- }
- void ledup(void)
- {
- while(1)
- {
- fun1();
- }
- }
- /***********下移****************/
- void fun2()
- {
- register unsigned char i,q,w;
- for(i=0;i<32;i++)
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=0x00;
- }
- if(i%2)delay(1);
- }
- for (w=0;w<TOTAL*2/BLKN;w++)
- {
- for(i=0;i<32;i++)
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=Bmp4[q+w*BLKN/2][i];
- }
- if(i%2)delay(60);
- }
- delay(250);
- }
-
- for(i=0;i<32;i++) //下联
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=0x00;
- }
- if(i%2)delay(60);
- }
- delay(250);
- }
- void leddown(void)
- {
- while(1)
- {
- fun2();
- }
- }
- /***********左移****************/
- void fun3()
- {
- register unsigned char i,j,k,l,q;
- for(i=0;i<32;i++)
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=0x00;
- }
- if(i%2)delay(1);
- }
- for(i=0;i<TOTAL1;i++)
- {
- for(j=0;j<2;j++)
- for(k=0;k<8;k++)
- {
- for(l=0;l<16;l++)
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[l*2+q*32]=dispram[l*2+q*32]<<1|dispram[l*2+1+q*32]>>7;
- if(q==BLKN/2-1)
- dispram[l*2+1+q*32]=dispram[l*2+1+q*32]<<1|Bmp2[i][l*2+j]>>(7-k);
- else
- dispram[l*2+1+q*32]=dispram[l*2+1+q*32]<<1|dispram[l*2+(q+1)*32]>>7;
- }
- }
- delay(10);
- }
- }
- delay(1);
-
- for(i=0;i<32;i++) //下联
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=0x00;
- }
- if(i%2)delay(10);
- }
- delay(10);
- }
- void ledleft(void)
- {
- while(1)
- {
- fun3();
- }
- }
- /***********特殊********************/
- void fun4()
- {
- register unsigned char i,q,w;
- for(i=0;i<32;i++)
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=0x00;
- }
- if(i%2)delay(1);
- }
- for(i=0;i<32;i++)
- {
- for(q=0,w=2;q<1,w<3;q++,w++)
- {
- dispram[i+q*32]=Bmp3[0][i];
- dispram[i+w*32]=Bmp3[0][i];
- }
- if(i%2)delay(40);
- }
- for(i=0;i<32;i++)
- {
- for(q=1,w=3;q<2,w<4;q++,w++)
- {
- dispram[i+q*32]=Bmp3[1][i];
- dispram[i+w*32]=Bmp3[1][i];
- }
- if(i%2)delay(60);
- }
- for(i=0;i<32;i++)
- {
- for(q=0;q<1;q++)
- {
- dispram[i+q*32]=Bmp3[2][i];
- dispram[i+w*32]=Bmp3[2][i];
- }
- for(q=1;q<2;q++)
- {
- dispram[i+q*32]=Bmp3[3][i];
- dispram[i+w*32]=Bmp3[3][i];
- }
- if(i%2)delay(60);
- }
- delay(250);
-
- for(i=0;i<32;i++) //下联
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=0xff;
- }
- if(i%2)delay(60);
- }
- delay(250);
- }
- void ledflash(void)
- {
- while(1)
- {
- fun4();
- }
- }
- /***********特殊********************/
- void ledorder(void)
- {
- while(1)
- {
- fun1();
- fun2();
- fun3();
- fun4();
- }
- }
- /**********键盘扫描程序************/
- void key_scan(void)
- {
- if((P2&0xff)!=0xf0)
- {
- delay20ms();
- if(S1==0)
- keyval=1;
- if(S2==0)
- keyval=2;
- if(S3==0)
- keyval=3;
- if(S4==0)
- keyval=4;
- if(S5==0)
- keyval=5;
- }
- }
- /***********主函数**********/
- void main(void)
- {
- register unsigned char i,q;
- SCON=0X00;
- TMOD=0X01;
- TR0=1;
- P1=0x3f;
- ET0=1;
- EA=1;
- keyval=0;
-
-
- while(1)
- {
- for(i=0;i<32;i++)
- {
- for(q=0;q<BLKN/2;q++)
- {
- dispram[i+q*32]=Bmp1[q][i];
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
16X32,FIVE FUNCTION.rar
(170.23 KB, 下载次数: 318)
|