广告屏,实现五个传输功能
单片机源程序如下:
- #include<reg52.h>
- #include<intrins.h>
- #define uint unsigned int
- #define uchar unsigned char
- #define T 100
- uint ii; //延时循环次数
- uint i;
- uchar v;
- sbit S1=P1^0; //ABCD"
- sbit S2=P1^1; //01234
- sbit S3=P1^2; //好好学习
- sbit S4=P1^3; //天天向上
- sbit S5=P1^4; //我叫林哲任
- sbit S6=P1^5; //生日快乐
- sbit S7=P1^6; //单片机
- sbit S8=P1^7; //O YE !
- uchar code PP[]=
- {
- /*-- " P " --*/
- 0x78,0x44,0x44,0x44,0x78,0x40,0x40,0x44
- };
- uchar code DZ[]=
- { /*-- A --*/
- 0x20,0x20,0x30,0x50,0x50,0x78,0x48,0xCC,
- /*-- B --*/
- 0xF0,0x48,0x48,0x70,0x48,0x48,0x48,0xF0,
- /*-- C --*/
- 0x78,0x88,0x80,0x80,0x80,0x80,0x88,0x70,
- /*-- D --*/
- 0xF0,0x48,0x48,0x48,0x48,0x48,0xF0,0x00,
-
- };
- uchar code S[]=
- {
- /*-- 1 --*/
- 0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,
- /*-- 6 --*/
- 0x20,0x20,0x20,0x3F,0x21,0x21,0x21,0x3F,
- /*-- 0 --*/
- 0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,
- /*-- 3 --*/
- 0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,
- /*-- 0 --*/
- 0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,
- /*-- 2 --*/
- 0x70,0x88,0x88,0x10,0x20,0x40,0x80,0xF8,
- /*-- 4 --*/
- 0x10,0x30,0x50,0x50,0x90,0x78,0x10,0x18,
- /*-- 0 --*/
- 0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,
- /*-- 2 --*/
- 0x70,0x88,0x88,0x10,0x20,0x40,0x80,0xF8,
- /*-- 1 --*/
- 0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,
- /*-- 3 --*/
- 0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,
- };
- uchar code SZ[]=
- {
- /*-- 好 --*/
- 0x20,0x4F,0xF2,0x94,0x6F,0x62,0x96,0x02,
- /*-- 好 --*/
- 0x20,0x4F,0xF2,0x94,0x6F,0x62,0x96,0x02,
- /*-- 学 --*/
- 0x54,0xDF,0xBA,0x08,0xDE,0x08,0x18,0x10,
- /*-- 习 --*/
- 0x00,0x7F,0x22,0x12,0x02,0x12,0x22,0x00,
- };
- uchar code AX[]=
- {
- /*-- 天 --*/
- 0x7E,0x10,0x10,0xFF,0x18,0x24,0x42,0x81,
- /*-- 天 --*/
- 0x7E,0x10,0x10,0xFF,0x18,0x24,0x42,0x81,
- /*-- 向 --*/
- 0x00,0x10,0x20,0x7E,0x42,0x5A,0x5A,0x00,
- /*-- 上 --*/
- 0x00,0x10,0x10,0x1C,0x10,0x10,0x7E,0x00,
- };
- uchar code RR[]=
- {
- /*-- 我 --*/
- 0x60,0x24,0x26,0xFF,0x2E,0x74,0x24,0x66,
- /*-- 叫--*/
- 0x00,0x0A,0x6A,0x6A,0x6E,0x02,0x02,0x00,
- /*-- 林--*/
- 0x24,0x24,0x7E,0x5A,0x24,0x24,0x24,0x24,
- /*-- 哲--*/
- 0x22,0xFF,0xF9,0x29,0x29,0x3F,0x21,0x3F,
- /*-- 任--*/
- 0x12,0x24,0x6C,0xBF,0x24,0x3F,0x24,0x3F,
- } ;
-
- uchar code SJ[]=
- {
- /*-- 生 --*/
- 0x10,0x50,0x7e,0x90,0x7c,0x10,0xfe,0x00,
- /*-- 日 --*/
- 0x7e,0x42,0x42,0x7e,0x42,0x42,0x7e,0x00,
- /*-- 快 --*/
- 0x48,0x48,0x5e,0xea,0xff,0x54,0x63,0x00,
- /*-- 乐 --*/
- 0x38,0x50,0x90,0xfe,0x38,0x54,0xb3,0x10,
- };
- uchar code HY[]=
- {
- /*--单 --*/
- 0x14,0x3E,0x2A,0x3E,0x2A,0x3E,0xFF,0x08,
- /*--片--*/
- 0x28,0x28,0x3E,0x20,0x3E,0x22,0x22,0x22,
- /*--机--*/
- 0x20,0x2E,0xFA,0x7A,0x7A,0x6A,0xAB,0x33,
- };
- uchar code HR[]=
- {
- /*-- O --*/
- 0x00,0x3C,0x42,0x42,0x42,0x42,0x3C,0x00,
- /*-- YE --*/
- 0x00,0x88,0x57,0x24,0x27,0x24,0x27,0x00,
- /*-- ! --*/
- 0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x18,
- };
- uchar code NN[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
- /*函数申明*/
- void display(void);
- void display_p(void);
- void display_XL(void);
- void display_SZ(void);
- void display_FK(void);
- void delay(uint m);
- /*************延时程序**************/
- void delay(uint m)
- {
- while(--m);
- }
- /*************初始化程序**************/
- void ini(void)
- {
- TMOD=0x01;
- TH0=(65536-46082)/256;
- TL0=(65536-46082)%256;
- ET0=1;
- EA=1;
- }
- /*************键扫描程序**************/
- uchar keyscan()
- {
- uchar tmp; //列号,行号
- P1=0xff; //发全行0扫描码
- if((P1&0xff)!=0xff) //若有键按下
- {
- delay(100); // 延时去抖
- if((P1&0xff)!=0xff) //有键按下
- {
- tmp=(P1&0xff);
- do{}while((P1&0xff)!=0xff);
- tmp=~tmp;
- return (tmp); //返回键值
- }
- }
- return (0); //无键按下,返回0
- }
- /*************主程序**************/
- void main(void)
- {
- uchar ii,v;
- int K;
- ini();
-
- while(1)
- { for(ii=0;ii<=T;ii++)//字符显示
- {
- for(i=0;i<=7;i++)//行列扫描
- {
- P0=PP[i];
- P2=NN[i];
- delay(100);
- P2=0xff;
- }
- }
- v=keyscan();
- if(v==1||v==2||v==4||v==8||v==16||v==32||v==64||v==128)
- {
- while(1)
- {
-
- switch(v)
- {
- case 1: P0=0X00; //ABCD//
- while(v==1||v==0)
- { P3=v^0xff;
- for(K=0;K<=3&&(v==1||v==0);K++)//控制显示字符数
- {
- for(ii=0;ii<=T&&(v==1||v==0);ii++)//字符显示
- { for(i=0;i<=7&&(v==1||v==0);i++)//行列扫描
- {P0=DZ[K*8+i];
- P2=NN[i];
- delay(100);
- P2=0xff;
- v=keyscan(); }
- }
- P2=0xff;
- } //调键扫描程序
- }
- break;
- case 2: P0=0X00;
- while(v==2||v==0) //01234//
- { P3=v^0xff;
- for(K=0;K<=10&&(v==2||v==0);K++)
- { for(ii=0;ii<=T&&(v==2||v==0);ii++)
- { for(i=0;i<=7&&(v==2||v==0);i++)
- {
- P0=S[K*8 +i];
- P2=NN[i];
- delay(100);
- P2=0xff;
- v=keyscan(); }
- }
- }
- P2=0xff;
- }
- break;
-
- case 4: P0=0X00;
- while(v==4||v==0) //好好学习//
- { P3=v^0xff;
- for(K=0;K<=3&&(v==4||v==0);K++)
- { for(ii=0;ii<=T&&(v==4||v==0);ii++)
- { for(i=0;i<=7&&(v==4||v==0);i++)
- {
- P0=SZ[K*8 +i];
- P2=NN[i];
- delay(100);
- P2=0xff;
- v=keyscan(); }
- }
- }
- P2=0xff;
- }
- break;
-
- case 8: P0=0X00;
- while(v==8||v==0) //天天向上//
- { P3=v^0xff;
- for(K=0;K<=3&&(v==8||v==0);K++)
- { for(ii=0;ii<=T&&(v==8||v==0);ii++)
- { for(i=0;i<=7&&(v==8||v==0);i++)
- {
- P0=AX[K*8 +i];
- P2=NN[i];
- delay(100);
- P2=0xff;
- v=keyscan(); }
- }
- }
- P2=0xff;
- }
-
- break;
- case 16: P0=0X00;
- while(v==16||v==0) //我叫刘人杰//
- { P3=v^0xff;
- for(K=0;K<=4&&(v==16||v==0);K++)
- { for(ii=0;ii<=T&&(v==16||v==0);ii++)
- { for(i=0;i<=7&&(v==16||v==0);i++)
- { P0=RR[K*8 +i];
- P2=NN[i];
- delay(100);
- P2=0xff;
- v=keyscan(); }
- }
- }
- P2=0xff;
- }
- break;
- case 32: P0=0X00; //生日快乐//
- while(v==32||v==0)
- { P3=v^0xff;
- for(K=0;K<=3&&(v==32||v==0);K++)
- { for(ii=0;ii<=T&&(v==32||v==0);ii++)
- { for(i=0;i<=7&&(v==32||v==0);i++)
- { P0=SJ[K*8 +i];
- P2=NN[i];
- delay(100);
- P2=0xff;
- v=keyscan(); }
- }
- }
- P2=0xff;
- }
- break;
-
- case 64: P0=0X00; //单片机//
- while(v==64||v==0)
- { P3=v^0xff;
- for(K=0;K<=2&&(v==64||v==0);K++)
- { for(ii=0;ii<=T&&(v==64||v==0);ii++)
- { for(i=0;i<=7&&(v==64||v==0);i++)
- { P0=HY[K*8 +i];
- P2=NN[i];
- delay(100);
- P2=0xff;
- v=keyscan(); }
- }
- }
- P2=0xff;
- }
- break;
- case 128: P0=0X00; //O YE !//
- while(v==128||v==0)
- { P3=v^0xff;
- for(K=0;K<=2&&(v==128||v==0);K++)
- { for(ii=0;ii<=T&&(v==128||v==0);ii++)
- { for(i=0;i<=7&&(v==128||v==0);i++)
- { P0=HR[K*8 +i];
- P2=NN[i];
- delay(100);
- P2=0xff;
- v=keyscan(); }
- }
- }
- P2=0xff;
- }
- break;
- }
- }
- }
- }
- }
复制代码
所有资料51hei提供下载:
广告屏.zip
(59.83 KB, 下载次数: 8)
|