新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)2408點(diǎn)陣時(shí)鐘電子制作

單片機(jī)2408點(diǎn)陣時(shí)鐘電子制作

作者: 時(shí)間:2016-11-25 來(lái)源:網(wǎng)絡(luò) 收藏
這是一個(gè)鐘電子制作,用單片機(jī)直驅(qū)點(diǎn)陣,這里用的是STC89C52,驅(qū)動(dòng)能力不是很好,有條件的話用STC12C5A60S,驅(qū)動(dòng)能力已經(jīng)比較好,屏的亮度會(huì)比較高。圖中是用STC89C52單片機(jī),直驅(qū)三個(gè)8*8的共陽(yáng)點(diǎn)陣屏,亮度還基本可以,白天看都很清楚!P0口需要接上1K的上拉電阻,P1-P3口分別接三個(gè)8*8屏的陰極,用去了單片機(jī)的全部32個(gè)I/O口。為了能調(diào)時(shí)間,P2口的P2.0-P2.6接屏的1-7列,P2.7口接一個(gè)按扭作于調(diào)時(shí)間,調(diào)整方法: 長(zhǎng)按一次是進(jìn)入調(diào)時(shí)狀態(tài),短按是加1,長(zhǎng)按二次是調(diào)分,短按是加1,長(zhǎng)按3次回復(fù)正常狀態(tài)! 感興趣的愛(ài)好者可以動(dòng)手實(shí)踐一下,體驗(yàn)一下電子制作點(diǎn)陣時(shí)鐘的樂(lè)趣。

本文引用地址:http://m.butianyuan.cn/article/201611/321448.htm



//單片機(jī)點(diǎn)陣電子鐘C語(yǔ)言程序
//MCU:STC89C52RD 晶振頻率:12MHZ
//編寫(xiě):桃源客 日期:2010-06-7
//電子小制作整理http://www.5imcu.net/轉(zhuǎn)載請(qǐng)保留。
#include
#include
#define uchar unsigned char //宏定義
#define uint unsigned int

sbit KEY=P2^7; //時(shí)調(diào)整鍵
uchar keymode; //鍵狀態(tài)
uchar keydate; //鍵值,
uint keycount; //鍵延時(shí)值
unsigned char c=0; //時(shí)分調(diào)整位置變量,0不調(diào),1時(shí)調(diào)時(shí),2時(shí)調(diào)分
bit D7,D6; //鍵值有效,長(zhǎng)按標(biāo)志,
bit SHAN; //閃爍標(biāo)志位
uchar second,minute,hour; //定義秒、分、時(shí)寄存器
//以下字模與ASCII對(duì)應(yīng)是,只要將 A-0x20就可以得到A的字模了
//高8*5寬 ASCII碼
//采用"字模提取軟件V2.2"
//提取方式:縱向取模,字節(jié)倒序
uchar code ASCII86[10][5]=
{
{0x3E,0x41,0x49,0x41,0x3E},//0
{0x00,0x42,0x7F,0x40,0x00},//1
{0x72,0x49,0x49,0x49,0x46},//2
{0x21,0x41,0x49,0x4D,0x32},//3
{0x18,0x14,0x12,0x7F,0x10},//4
{0x27,0x45,0x45,0x45,0x38},//5
{0x3C,0x4A,0x49,0x49,0x31},//6
{0x41,0x21,0x11,0x09,0x07},//7
{0x36,0x49,0x49,0x49,0x36},//8
{0x46,0x49,0x49,0x29,0x16},//9
};
uchar code seg[24][3]=
{
{0xfe,0xff,0xff},
{0xfd,0xff,0xff},
{0xfb,0xff,0xff},
{0xf7,0xff,0xff},
{0xef,0xff,0xff},
{0xdf,0xff,0xff},
{0xbf,0xff,0xff},
{0x7f,0xff,0xff},
{0xff,0xfe,0xff},
{0xff,0xfd,0xff},
{0xff,0xfb,0xff},
{0xff,0xf7,0xff},
{0xff,0xef,0xff},
{0xff,0xdf,0xff},
{0xff,0xbf,0xff},
{0xff,0x7f,0xff},
{0xff,0xff,0xfe},
{0xff,0xff,0xfd},
{0xff,0xff,0xfb},
{0xff,0xff,0xf7},
{0xff,0xff,0xef},
{0xff,0xff,0xdf},
{0xff,0xff,0xbf},
{0xff,0xff,0x7f}
}; //P1,P3,P2掃描列選碼
uchar disbuf[]={0,0,0,0,0,0};//定義緩沖數(shù)組區(qū)
void delay(uchar t); //延時(shí)函數(shù)
void init(); //初始化函數(shù)
void display(); //顯示函數(shù)


上一頁(yè) 1 2 下一頁(yè)

評(píng)論


技術(shù)專區(qū)

關(guān)閉