本作品采用STC15F2K60S2單片機和OLED12864四線(IIC)設計,在oled顯示。
1.自定義的顯示函數以滿足顯示需求,顯示實時溫度,光敏電阻采光度和1302時鐘顯示。
2.簡化的字庫以滿足單片機4K Flash的容量需求,
請注意!為防止低成本盜用(雖然寫的不怎么樣),僅展示主程序文件源碼,在附件- #include <STC15F2K60S2.H>
- #include "ds18b20.h"
- #include "time.h"
- #include "stdio.h"
- #include "intrins.h"
- #include "cod.h"
- #include "LQ12864.h"
- #include "DS1302.h"
- #include "ADC.h"
- unsigned char Wendu,shi,fen,miao,ADC;
- //unsigned int xdata a[100];
- void main(void)
- {
- //unsigned char fg=40;
- unsigned char code tr[][20]={"0","1","2","3","4","5","6","7","8","9"};
- chu_shi(); //開發板初始化
- OLED_Init(); //OLED初始化
- DS1302_Init(); //DS1302初始化
- ADC_Init(0x01);
-
- while(1)
- {
- Wendu=Temper_Read();
- ADC=ADC_Read();
- miao=Ds1302_Single_Byte_Read(0x81);
- fen=Ds1302_Single_Byte_Read(0x83);
- shi=Ds1302_Single_Byte_Read(0x85);
-
- // OLED_P8x16Str(1,0,tr[fg/10]);
- // OLED_P8x16Str(9,0,tr[fg%10]);
- // sprintf(a,"%d", 123);
- OLED_P16x16Ch(2,0,8);
- OLED_P8x16Str(20,0,"203");
- OLED_P16x16Ch(50,0,1);
- OLED_P16x16Ch(66,0,2);
- OLED_P16x16Ch(82,0,3);
- OLED_P16x16Ch(100,0,8);
-
- OLED_P16x16Ch(1,2,4);
- OLED_P16x16Ch(17,2,5);
- OLED_P8x16Str(30,2,":");
- OLED_P8x16Str(37,2,tr[Wendu/10]);
- OLED_P8x16Str(45,2,tr[Wendu%10]);
- OLED_P16x16Ch(53,2,9);
- OLED_P8x16Str(61,2,"C");
-
-
- OLED_P16x16Ch(1,4,6);
- OLED_P16x16Ch(17,4,7);
- OLED_P8x16Str(30,4,":");
- OLED_P8x16Str(38,4,tr[shi/16]);
- OLED_P8x16Str(46,4,tr[shi%16]);
- OLED_P8x16Str(54,4,"-");
- OLED_P8x16Str(62,4,tr[fen/16]);
- OLED_P8x16Str(70,4,tr[fen%16]);
- OLED_P8x16Str(78,4,"-");
- OLED_P8x16Str(86,4,tr[miao/16]);
- OLED_P8x16Str(94,4,tr[miao%16]);
-
-
- OLED_P16x16Ch(1,6,10);
- OLED_P16x16Ch(17,6,11);
- OLED_P8x16Str(30,6,":");
- OLED_P8x16Str(38,6,tr[ADC/100]);
- OLED_P8x16Str(46,6,tr[ADC/10%10]);
- OLED_P8x16Str(54,6,tr[ADC%10]);
- }
- }
復制代碼
中有完整版。
|