|
這款結構簡單的單片機控制8×16點陣時鐘是在網上看到的,由于結構簡單,制作容易,感覺對初學者比較有用,所以就收集到我的空間,原作者用洞洞板制作了這塊點陣時鐘,用的是兩塊88點陣制作做,可以顯示時間及一些簡單的祝福語,實物中是用三極管做的驅動,P2,P0,P1直接驅動顯示,相關資料及C程序、電路圖比較齊全,需要的請自己下載附件。
附件:
結構簡單的單片機控制8×16點陣時鐘.zip
(667.48 KB, 下載次數: 132)
2015-4-11 19:31 上傳
點擊文件名下載附件
源碼: - #include <reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar fen,shi,miao,miao1,fen1,fen2,shi1,shi2,count,tt;
- uchar code mm[]={0x14,0x00,};//秒點數組
- uchar code TAB[]=
- {
- 0x7F,0x41,0x7F,0x00,//0
- 0x42,0x7F,0x40,0x00,//1
- 0x79,0x49,0x4F,0x00,//2
- 0x49,0x49,0x7F,0x00,//3
- 0x0F,0x08,0x7F,0x00,//4
- 0x4F,0x49,0x79,0x00,//5
- 0x7F,0x49,0x79,0x00,//6
- 0x01,0x01,0x7F,0x00,//7
- 0x7F,0x49,0x7F,0x00,//8
- 0x4F,0x49,0x7F,0x00,//9
- };//數字組
- uchar code lie[]=
- {
- 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
- }; //列掃描
- uchar code TAB2[]={
- /*-- 空白區 --*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- /*-- 文字: 李 --*/
- /*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
- 0x00,0x80,0x00,0x80,0x3F,0xFE,0x01,0xC0,0x02,0xA0,0x0C,0x90,0x70,0x8C,0x27,0xFB,
- 0x01,0x00,0x00,0x80,0x7F,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x00,0x40,
- /*-- 文字: 斯 --*/
- /*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
- 0x30,0x44,0x0E,0x44,0x02,0xFF,0x02,0x44,0x02,0x7C,0x7E,0x44,0x12,0x44,0x12,0x7C,
- 0x12,0x44,0x12,0x44,0x12,0xFF,0x12,0x00,0x11,0x24,0x11,0x46,0x10,0xC1,0x10,0x00,
- /*-- 文字: 羽 --*/
- /*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
- 0x00,0x00,0x3F,0x7E,0x20,0x40,0x20,0x40,0x22,0x44,0x24,0x48,0x24,0x48,0x20,0x60,
- 0x28,0x50,0x24,0x48,0x23,0x46,0x20,0x40,0x20,0x40,0x20,0x40,0x28,0x50,0x10,0x20,
- /*-- 文字: 小 --*/
- /*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
- 0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x02,0x90,0x04,0xB0,0x08,0x98,0x18,0x88,
- 0x30,0x84,0x60,0x82,0x20,0x81,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x00,0x40,
- /*-- 文字: 寶 --*/
- /*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
- 0x00,0x40,0x00,0x80,0x7F,0xFE,0x20,0x02,0x10,0x01,0x1F,0xFC,0x00,0x80,0x00,0x80,
- 0x00,0x80,0x1F,0xF8,0x02,0x80,0x04,0x80,0x0C,0x80,0x04,0x80,0x7F,0xFE,0x00,0x00,
- /*-- 文字: 貝 --*/
- /*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
- 0x00,0x00,0x0F,0xF8,0x08,0x08,0x08,0x08,0x08,0x88,0x08,0x88,0x08,0x88,0x08,0x88,
- 0x08,0x88,0x08,0x88,0x08,0x88,0x01,0x40,0x06,0x20,0x18,0x18,0x10,0x06,0x00,0x00,
- /*-- 文字: 我 --*/
- /*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
- 0x02,0x60,0x0A,0x1C,0x12,0x10,0x12,0x10,0x02,0x10,0x7F,0xFF,0x02,0x10,0x12,0x10,
- 0x14,0x70,0x0C,0x1C,0x04,0x13,0x0A,0x10,0x49,0x90,0x50,0x10,0x60,0x14,0x40,0x08,
- /*-- 文字: 愛 --*/
- /*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
- 0x1F,0x00,0x09,0xFC,0x08,0x48,0x04,0x90,0x7F,0xFC,0x40,0x44,0x00,0x42,0x3F,0xFC,
- 0x00,0x20,0x0F,0xE0,0x04,0x30,0x02,0xD0,0x03,0x08,0x0C,0xC6,0x70,0x31,0x20,0x0C,
- /*-- 文字: 你 --*/
- /*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
- 0x00,0x90,0x01,0x90,0x20,0x88,0x7F,0xC8,0x20,0x44,0x12,0x2C,0x02,0x16,0x0A,0x45,
- 0x12,0xC4,0x12,0x44,0x22,0x24,0x62,0x24,0x22,0x14,0x02,0x84,0x01,0x04,0x00,0x00,
- /*-- 空白區 --*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
- uchar code lie2[]={
- 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,
- };
- /******************
- 延時程序
- *****************/
- void delay(uint k)
- {
- uint i,j;
- for(i=k;i>0;i--)
- for(j=110;j>0;j--);
- }
- /******************
- 顯示程序
- *****************/
- void disp8_1(uchar m)
- {
- uint e;
- for(e=0;e<4;e++)
- {
- P0=lie[e];
- P1=lie[e+8];
- P2=TAB[m*4+e];
- delay(1);
- P2=0x00; //消影
- }
- }
- void disp8_2(uchar n)
- {
- uint f;
- for(f=0;f<4;f++)
- {
- P0=lie[f+4];
- P1=lie[f+8+4];
- P2=TAB[n*4+f];
- delay(1);
- P2=0x00; //消影
- }
-
- }
- void disp8_3(uchar o)
- {
- uint g;
- for(g=0;g<4;g++)
- {
- P0=lie[g+9];
- P1=lie[g+8+9];
- P2=TAB[o*4+g];
- delay(1);
- P2=0x00; //消影
- }
- }
- void disp8_4(uchar p)
- {
- uint h;
- for(h=0;h<4;h++)
- {
- P0=lie[h+13];
- P1=lie[h+8+13];
- P2=TAB[p*4+h];
- delay(1);
- P2=0x00; //消影
- }
-
- }
- void disp8_5(uchar q)
- {
- uint h;
- for(h=0;h<2;h++)
- {
- P0=lie[h+7];
- P1=lie[h+7+8];
- P2=mm[q]; //秒點
- delay(1);
- P2=0x00; //消影
- }
-
- }
- void disp_wz()
- {
- uint a,b,c;
- P2=0x01;
- for(a=0;a<152;a++) //掃描全幅
- {
- for(b=0;b<8;b++) //移動速度
- {
- for(c=0;c<8;c++) //掃描1幀
- {
- P2=lie2[c];
- P1=~TAB2[2*c+2*a];
- P0=~TAB2[2*c+1+2*a];
- delay(1);
- P1=0xff; //消影
- P0=0xff; //消影
- }
- }
- }
- tt=0;//開始顯示時鐘
- }
- /******************
- 初始化程序
- *****************/
- inti()
- {
- tt=0;
- shi=1;
- fen=3;
- miao=0;
- miao1=0;
-
- shi1=shi/10;//分離時
- shi2=shi%10;
- fen1=fen/10;//分離分
- fen2=fen%10;
-
- P1=0xff;
- TMOD=0x01;
- TH0=(65536-45872)/256;
- TL0=(65536-45872)%256;
- EA=1;
- ET0=1;
- TR0=1;
- }
- /******************
- 主程序
- *****************/
- void main()
- {
- inti();
- while(1)
- {
- if(tt<=20)
- {
- disp8_1(shi2);//顯示小時
- disp8_2(shi1);//顯示小時
- disp8_3(fen2);//顯示分鐘
- disp8_4(fen1);//顯示分鐘
- disp8_5(miao);//秒點顯示
- }
- else
- {
- disp_wz();
- }
- }
- }
- /******************
- 中斷程序
- *****************/
- void timer0() interrupt 1
- {
- shi1=shi%10;//分離時
- shi2=shi/10;
- fen1=fen%10;//分離分
- fen2=fen/10;
- TH0=(65536-45872)/256;
- TL0=(65536-45872)%256;
- count++;
- if(count==10)
- {
- count=0;
- tt++;
- miao++;
- miao1++;
- if(miao==2){miao=0;}
- if(miao1==120)
- {
- miao1=0;
- fen++;
- if(fen==60)
- {
- fen=0;
- shi++;
- if(shi==24){shi=0;}
- }
-
- }
- }
- }
復制代碼
|
|