DS18B20智能温度传感器驱动程序

传感器网CGQ.BZ · 2016-09-08 17:34:23 · 1007次浏览

/*********端口定义,可以修改*****************/

sbit ledrs="P2^3; //读写控制字    

void prints(uchar * str)      
{   uchar i = 0;
    while(str[i] != '\0')
    {
        write_data(str[i++]);
    }
}
uchar buffer[5];
void IntToStr(uint t, uchar *str,uchar n) 
{
uchar a[5]; char i, j;    //取得整数值到数组                                  
 a[0]=t/100;   //百位          
 a[1]=(t/10)%10;//十位                                      
 a[2]=t%10;    //个位                     
                                     
                                                      
 for(i="0;" i<3; i++)         //转成ASCII码               
  a[i]=a[i]+'0';                                     
 for(i="0;" a[i]=='0' && i<=1; i++);                      
 for(j="3-n;" j

文章推荐: