數碼管滾動顯示 I LOVE YOU- /***************************************************
- 功能:數碼管移動顯示I LUVE YOU
- 單片機:STC12C5A60S2
- 晶振: 11.0592M
- 作者;蘇義江改編于黑51
- 時間:2015-7-23
- *****************************************************/
- #include<reg52.h>
- #include<intrins.h>
- sbit wela=P0^6;
- sbit dula=P0^7;
- //共陽I LOVE YOU斷碼 0XFF起空格作用
- uchar code duanma[]={0xf9,0xff,0xc7,0xc0,0xc1,0x86,0xff,0x8d,0xc0,0xc1,0xff};
- //共陰I LOVE YOU斷碼
- //uchar code duanma[]={0x06,0x00,0x38,0x3f,0x3e,0x79,0x00,0x6e,0x3f,0xbe,0x00};
- uchar code weima[]={0xfe,0xfd,0xfb,0xf7};//位碼
- uchar smg_change[11];//9個數據
- void delay(uint z)
- {
- uint x,y;
- for(x=z;x>0;x--)
- for(y=50;y>0;y--);
- }
- void display(uchar f,uchar n )//顯示位數和內容
- {
- static uchar i;
- P2=0XFF;
- delay(2);//延時起消隱作用
- wela=1;
- P2=weima[f+i];
- wela=0;
- P2=0Xff;
- dula=1;
- P2=smg_change[i];
- dula=0;
- P2=0XFF;
- i++;
- if(i==n)
- i=0;
- }
- void jiaohuan()//移位函數
- {
- uchar i,dd;
- for(i=0;i<10;i++)//顯示內容的數量減1
- {
- dd=smg_change[i];
- smg_change[i]=smg_change[i+1];
- smg_change[i+1]=dd;
- }
- }
- void main()
- {
- uchar y,i;
- uint t;
- for(i=0;i<11;i++)//顯示8個內容
- //for(i=0;i<11;i++)
- {
- smg_change[i]=duanma[i];
- }
- while(1)
- {
- display(y,4);//4位數碼管顯示Y個內容
- t++;
- if(t==5000)//顯示的速度
- {
- t=0;
- jiaohuan();
- }
- }
- }
復制代碼 |