多多指教
單片機源程序如下:
- #include<reg51.h>
- #define uchar unsigned char
- #define uint unsigned int
- sbit TR =P2^6;
- sbit led0=P2^7;
- sbit OA =P1^0; //行控制線A
- sbit OB =P1^1; //行控制線B
- sbit OC =P1^2; //行控制線C
- sbit OD =P1^3; //行控制線D
- sbit LE=P2^0; //鎖存
- sbit CLK=P2^1; //時鐘
- sbit OE=P2^3; //片選
- sbit DR1= P1^4; //紅色數(shù)據(jù)1
- sbit DR2= P1^6; //紅色數(shù)據(jù)2
- sbit DG1= P1^5; //綠色數(shù)據(jù)1
- sbit DG2= P1^7; //綠色色數(shù)據(jù)2
- unsigned int a,b,c,d,i,j,x,y=32,led31,led32,led41,led42;
- void delay(uint i);
- const uchar code hz[][32]={
- 0x00,0x00,0x00,0x10,0x00,0x30,0x00,0x20,0x07,0xA0,0x1B,0x7E,0x02,0x46,0x06,0xE8,
- 0x03,0x60,0x04,0x70,0x18,0xC8,0x01,0x86,0x03,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x20,0x00,0xC0,0x11,0x9E,0x19,0x36,0x01,0x34,0x01,0xFC,0x19,0xBC,
- 0x08,0x20,0x08,0x20,0x04,0x20,0x3F,0xF0,0x00,0x0F,0x00,0x07,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x60,0x00,0x48,0x00,0x58,0x07,0xF0,0x02,0x48,0x00,0xFC,0x07,0xC0,
- 0x09,0x80,0x01,0x40,0x02,0x40,0x0C,0x40,0x18,0x41,0x00,0x3F,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x03,0x10,0x02,0x10,0x02,0x22,0x1A,0x2E,0x1A,0x78,0x1A,0xD8,0x1B,0x10,
- 0x1A,0x1F,0x1A,0xFB,0x12,0xD9,0x02,0x7B,0x02,0x46,0x02,0x00,0x00,0x00,0x00,0x00,
- };
- const uchar code hz2[][32]={0x00};
- //const uchar code hz3[][32]={0x00};
- const uchar code hz5[][32]=
- {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x18,0x32,0x7C,0x60,0xC0,0x40,0x00,
- 0x00,0x10,0x0C,0x20,0x1C,0x20,0x1E,0x60,0x0F,0xC0,0x0F,0x80,0x03,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0xF0,0x03,0xE0,0x00,0x00,0x00,0x1C,0x00,0xFC,0x0F,0xE0,
- 0x09,0xC0,0x01,0x40,0x02,0x40,0x04,0x40,0x1C,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x18,0x00,0x18,0x03,0x18,0x06,0x18,0x06,0xFE,0x0C,0xB8,0x0D,0x1F,0x14,0x7F,
- 0x05,0x90,0x04,0x10,0x04,0x10,0x04,0x10,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,
- 0x00,0x60,0x00,0x20,0x00,0x1C,0x01,0xF0,0x01,0x3C,0x03,0xF8,0x03,0x50,0x06,0xFC,
- 0x05,0xD0,0x08,0x3F,0x1B,0xD0,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x00,
- };
- const uchar code hz6[][32]= {
- 0x00,0xE0,0x01,0x00,0x02,0x00,0x0C,0x00,0x08,0x00,0x10,0x7C,0x10,0x82,0x21,0x11,0x21,0x35,0x27,0x3D,0x39,0x19,0x23,0x01,0x2C,0x82,0x30,0x7C,0x20,0x00,0x20,0x00,
- 0x1C,0x00,0x07,0x00,0x01,0x80,0x00,0x40,0x00,0x40,0x3E,0x60,0x41,0x20,0x88,0x90,0x9A,0xD0,0x9E,0xB0,0x8C,0xD0,0x80,0xB0,0x41,0x10,0x3E,0x10,0x00,0x10,0x00,0x10,
- 0x00,0x00,0x00,0x80,0x01,0x80,0x01,0x00,0x03,0x60,0x0F,0xC0,0x7F,0x80,0x0F,0x00,0x19,0xC0,0x30,0x78,0x77,0xCC,0x09,0x60,0x0B,0xA0,0x05,0x20,0x07,0x40,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x02,0xF8,0x5F,0x58,0x6A,0x50,0x4A,0x60,0x5B,0x80,0x22,0x00,0x02,0x02,0x01,0x02,0x01,0x86,0x00,0x78,0x00,0x00,0x08,0x00,
- };
- const uchar code hz7[][32]= {
- 0x20,0x00,0x20,0x00,0x20,0x07,0x30,0x02,0x2C,0x01,0x23,0x00,0x20,0xBC,0x78,0x43,0xD4,0x20,0x93,0x20,0x90,0xE0,0x90,0x40,0xC8,0x40,0x78,0x40,0x0D,0x80,0x00,0x00,
- 0x10,0x10,0xF0,0x10,0xA0,0x30,0x60,0xD0,0xC1,0x10,0x02,0x38,0x34,0x56,0xC5,0x93,0x07,0x11,0x01,0x11,0x01,0x11,0x01,0x33,0x01,0xD2,0x00,0x1C,0x00,0x20,0x00,0x20,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x0F,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x88,0x00,0xCC,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x8C,0xF0,0x8F,0xE0,0x0E,0x00,0x3C,0x00,0xEC,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0E,0x00,0x00,0x00,
- };
- const uchar code xiao[][32]={0X00
- };
- uchar clear[8]={0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF};
- uchar clear1[8]={0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF};
- uchar clear2[8]={0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF};
- void SendDate(unsigned char DataR1,unsigned char DataG1,unsigned char DataR2,unsigned char DataG2)
- {
- unsigned char k;
- for(k = 0; k<8; k++)
- {
- DR1=DataR1 & 0x01;
- DG1=DataG1 & 0x01;
- DR2=DataR2 & 0x01;
- DG2=DataG2 & 0x01;
- CLK = 0;
- CLK = 1;
- DataR1 >>= 1;
- DataG1 >>= 1;
- DataR2 >>= 1;
- DataG2 >>= 1;
- }
- }
- void led_gang(uchar shang[][32],uchar xia[][32])
- {
-
- for(x=4;x>0;x--)
- {
- SendDate(0x00,xia[x-1][y-1],0x00,shang[x-1][y-1]);
- SendDate(0x00,xia[x-1][y-2],0x00,shang[x-1][y-2]);
- }
- y=y-2;
- if(y==0)y=32;
- OE=1; //關(guān)顯示屏片選
- LE=1;
- LE=0; //輸出鎖存
- OE=0; //開顯示屏片選
- }
- void hengyi()
- {
- static int m=0;
- static int i=63;
- for(x=8;x>0;x--)
- { SendDate(0x00,0x00,clear[x-1],0x00);
- }
- m++;
- if(m%16==0)
- {
- m=0;
- clear[i/8]<<=1;
- i--;if(i<0)i=63;
- }
-
- OE=1; //關(guān)顯示屏片選
- LE=1;
- LE=0; //輸出鎖存
- OE=0; //開顯示屏片選
- }
- void zi_yi_ru(uchar ZK[][32],uchar ZK1[][32])
- {
- static int m=0;
- static int i=63;
- int byte,temp;//一行有8個字節(jié) 即64列
- static int cgg,cg;
- for(byte=0;byte<8;byte++) //每次進(jìn)來都給clear賦值點陣板的一行數(shù)據(jù)
- {
- clear[byte]=ZK[byte/2][32-2*(m+1)+byte%2];
- clear1[byte]=ZK1[byte/2][32-2*(m+1)+byte%2];
- }
- m++; //送一行數(shù)據(jù)m+1 即總共送16行數(shù)據(jù)
- if(m%16==0)
- { m=0;
- i--;if(i<0)i=63;
- }
-
- if(cgg>127){cgg=0;cg++; if(cg==8)cg=0;}
- cgg++;
- temp=cg;
- for(;temp>0;temp--)
- {clear[8-temp]=0;
- clear1[8-temp]=0;
- }
-
- for(x=8;x>0;x--) //送入64位數(shù)據(jù) 即一行的數(shù)據(jù)
- {
- if((8-cg)==x)
- SendDate(clear1[x-1]&(0xff<<(8-i%8)),0x00,clear[x-1]&(0xff<<(8-i%8)),0x00);
- else
- SendDate(clear1[x-1],0x00,clear[x-1],0x00);
- }
- //所以每一次都要給clear賦值一次
- OE=1; //關(guān)顯示屏片選
- LE=1;
- LE=0; //輸出鎖存
- OE=0; //開顯示屏片選
- }
- void clear_0()
- {
- uchar i;
- for(i=0;i<8;i++)
- {
- clear[i]=0X00;clear1[i]=0X00;clear2[i]=0X00;
- }
- }
- void gundong(uchar HK2[][32],uchar HK3[][32])
- {
- static int time_64=128*8-1;
- static int m;
- int temp,j,h;
- // static char yi=7;
- char yi;
- temp=time_64/128;
- yi=time_64/16%8;
- for(j=0;j<temp;j++)
- {clear[j]=0;clear1[j]=0;clear2[j]=0;}
- for(j=temp,h=7;j<8;j++,h--)
- {
- { if(h%2==1)
- {
- if(h==7)
- {//clear[j]=(HK[3-h/2][32-2*(m+1)]>>yi)|(HK[3-h/2][32-2*(m+1)+1]<<(8-yi));
- clear1[j]=(HK2[3-h/2][32-2*(m+1)]>>yi);//|(HK2[3-h/2][32-2*(m+1)+1]<<(8-yi));
- clear2[j]=(HK3[3-h/2][32-2*(m+1)]>>yi);//|(HK3[3-h/2][32-2*(m+1)+1]<<(8-yi));
- }
- else
- {//clear[j]=(HK[3-h/2][32-2*(m+1)]>>yi)|(HK[3-h/2][32-2*(m+1)+1]<<(8-yi));
- clear1[j]=(HK2[3-h/2][32-2*(m+1)]>>yi)|(HK2[3-h/2-1][32-2*(m+1)+1]<<(8-yi));
- clear2[j]=(HK3[3-h/2][32-2*(m+1)]>>yi)|(HK3[3-h/2-1][32-2*(m+1)+1]<<(8-yi));}
- }
- else
- {
- // if(temp==0&&h<=1)//h=0
- // {
- // //clear[j]=(HK[3-h/2][32-2*(m+1)+1]>>yi)|(HK[3-h/2+1][32-2*(m+1)]<<(8-yi));
- // clear1[j]=(HK2[3-h/2][32-2*(m+1)+1]>>yi);//|(HK2[3-h/2+1][32-2*(m+1)]<<(8-yi));
- // clear2[j]=(HK3[3-h/2][32-2*(m+1)+1]>>yi);//|(HK3[3-h/2+1][32-2*(m+1)]<<(8-yi));
- // }
- // else
- { //clear[j]=(HK[3-h/2][32-2*(m+1)+1]>>yi)|(HK[3-h/2+1][32-2*(m+1)]<<(8-yi));
- clear1[j]=(HK2[3-h/2][32-2*(m+1)]<<(8-yi))|(HK2[3-h/2][32-2*(m+1)+1]>>yi);
- clear2[j]=(HK3[3-h/2][32-2*(m+1)]<<(8-yi))|(HK3[3-h/2][32-2*(m+1)+1]>>yi); }
-
- }
- }
-
- }
- m++; //送一行數(shù)據(jù)m+1 即總共送16行數(shù)據(jù)
- if(m%16==0)
- { m=0;//yi--;if(yi<0)yi=0;
- // i--;if(i<0)i=63; //i表示送完64列數(shù)據(jù)了
- }
- time_64--;
- if(time_64==0){time_64=128*8-1; }
- for(x=8;x>0;x--) //送入64位數(shù)據(jù) 即一行的數(shù)據(jù)
- {
- SendDate(0x00,clear2[x-1],0x00,clear1[x-1]);
- }
- //所以每一次都要給clear賦值一次
- OE=1; //關(guān)顯示屏片選
- LE=1;
- LE=0; //輸出鎖存
- OE=0; //開顯示屏片選
- }
- //void zi_yi_ru2(uchar ZK[][32])
- //{
- //
- // static int m=0;
- // static int i=63;
- // int byte,temp;//一行有8個字節(jié) 即64列
- // static int cgg,cg;
- // for(byte=0;byte<8;byte++) //每次進(jìn)來都給clear賦值點陣板的一行數(shù)據(jù)
- // {
- // clear[byte]=ZK[byte/2][32-2*(m+1)+byte%2];
- // }
- //
- //
- // m++; //送一行數(shù)據(jù)m+1 即總共送16行數(shù)據(jù)
- // if(m%16==0)
- // {
- //
- // m=0;
- // // clear[i/8]=0; //先把16行數(shù)據(jù)顯示一遍 再向左移動一位
- // i--;if(i<0)i=63;
- // }
- //
- // if(cgg>127){cgg=0;cg++; if(cg==8)cg=0;}
- // cgg++;
- // temp=cg;
- // for(;temp>0;temp--)
- // {clear[8-temp]=0;}
- //
- //
- // for(x=8;x>0;x--) //送入64位數(shù)據(jù) 即一行的數(shù)據(jù)
- // {
- // if((8-cg)==x)
- // SendDate(0x00,clear[x-1]&(0xff<<i%8),0x00,0x00);
- // else
- // SendDate(0x00,clear[x-1],0x00,0x00);
- // }
- // //所以每一次都要給clear賦值一次
- //
- // OE=1; //關(guān)顯示屏片選
- // LE=1;
- // LE=0; //輸出鎖存
- // OE=0; //開顯示屏片選
- //
- //
- //
- //
- //
- //}
- void scan()
- {
-
- OA=a;OB=b;OC=c;OD=d;
- a++;
- if(a==2){a=0;b++;}
- if(b==2){b=0;c++;}
- if(c==2){c=0;d++;}
- if(d==2){d=0;}
-
- }
- void gunru(uchar shang[][32],uchar xia[][32])
- {
- unsigned int m,n;
- for(m=0;m<64;m++)
- { for(n=0;n<16;n++)
- {
- gundong(shang,xia);
- scan();
-
- }
- // delay(100);
- }
- }
- void gunchu(uchar shang[][32],uchar xia[][32])
- {
- unsigned int m,n;
- for(m=0;m<64;m++)
- { for(n=0;n<16;n++)
- {
-
- zi_yi_ru(shang,xia);//hengyi();
- scan();
-
- }
-
- }
- }
- //void full_clear2()
- //{
- // unsigned int m,n;
- // for(m=0;m<64;m++)
- // { for(n=0;n<16;n++)
- // {
- // zi_yi_ru2(hz3);//hengyi();
- // scan();
- //
- // }
- // }
- //}
- void soft_reset(void)
- {
- ((void (code *) (void)) 0x0000) ();
- }
- /*****************延時函數(shù):大約1ms************************/
- void delay(uint i)
- {
- uint j,k;
- for(j=i;j>0;j--)
- for(k=1250;k>0;k--);
- }
- void main()
- {
- unsigned int m,n,e,d,g,gang=10;
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
64乘32點陣板.c.rar
(73.83 KB, 下載次數(shù): 20)
2017-10-22 10:45 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|