|
部分代碼:
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
//--定義使用的IO口--//
#define GPIO_DIG P1 //段選
#define GPIO_PLACE P2 //位選
sbit K1=P3^6;
sbit K2=P3^7;
sbit DS=P3^0; //define interface
signed long int temp; // variable of temperature
uchar state=0;
unsigned char code DIG_PLACE[8] = {
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//位選控制 查表的方法控制
unsigned char code DIG_CODE[] = {
0xFC, //"0"
0x60, //"1"
0xDA, //"2"
0xF2, //"3"
0x66, //"4"
0xB6, //"5"
0xBE, //"6"
0xE0, //"7"
0xFE, //"8"
0xF6, //"9"
0xEE, //"A"
0x3E, //"B"
0x9C, //"C"
0x7A, //"D"
0x9E, //"E"
0x8E, //"F"
0x6E, //"H"
0x1C, //"L"
0xEC, //"n"
0x7C, //"u"
0xCE, //"P"
0x3A, //"o"
0x02, //"-"
0x00, //熄滅
0x00 //自定義
};
unsigned char DisplayData[8];
//用來存放要顯示的8位數(shù)的值
void delay(uint count) //delay
{
uint i;
while(count)
{
i=200;
while(i>0)
i--;
count--;
}
}
void dsreset(void) //send reset and initialization command
{
uint i;
DS=0;
i=103;
while(i>0)i--;
DS=1;
i=4;
while(i>0)i--;
}
|
-
1.jpg
(87.03 KB, 下載次數(shù): 36)
下載附件
2019-12-6 21:53 上傳
-
-
ds18b20.zip
2019-12-6 21:55 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
74.06 KB, 下載次數(shù): 21, 下載積分: 黑幣 -5
|