|
在網上找了一下ds1302的相關程序,自己仿照寫的一些程序,在LCD1602上面顯示了日期時間
附上仿真圖
- //這個是main.c
- #include <reg52.h>
- #include "lcd1602.h"
- #include "ds1302.h"
- void Delay(unsigned int count)
- {
- unsigned int i,j;
- for(i=0;i<count;i++)
- for(j=0;j<120;j++);
- }
- main()
- {
- SYSTEMTIME CurrentTime;//現在時間
- lcd_init();
- Initial_DS1302();
-
- while(1)
- {
- DS1302_GetTime(&CurrentTime);
- TimeToStr(&CurrentTime);
- GotoXY(6,1);
- Print(CurrentTime.TimeString);
- DateToStr(&CurrentTime);
- GotoXY(4,0);
- Print(CurrentTime.DateString);
- Delay(400);
- }
-
- }
復制代碼
|
|