新聞中心

        pt100測溫程序-LCD1602

        作者: 時(shí)間:2016-11-13 來源:網(wǎng)絡(luò) 收藏

        本文引用地址:http://www.104case.com/article/201611/316093.htm

        #include"at89X52.h"

        sbitLCD_RS=P2^0;

        sbitLCD_RW=P2^1;

        sbitLCD_E=P2^2;

        sbitADC_CS=P2^3;

        sbitADC_WR=P3^6;

        sbitADC_RD=P3^7;

        #defineLCD_DATAP0

        unsignedcharLcdBuf1[10]="";

        unsignedcharcodeBmp001[][8]=

        {

        {0x06,0x09,0x09,0x06,0x00,0x00,0x00,0x00},

        {0x06,0x09,0x10,0x10,0x10,0x09,0x06,0x00}

        };

        voiddellay(unsignedinth)

        {

        while(h--);//0.01MS

        }

        voidWriteDataLcd(unsignedcharwdata)

        {

        LCD_DATA=wdata;

        LCD_RS=1;

        LCD_RW=0;

        LCD_E=0;

        dellay(1000);

        LCD_E=1;

        }

        voidWriteCommandLcd(unsignedcharwdata)

        {

        LCD_DATA=wdata;

        LCD_RS=0;

        LCD_RW=0;

        LCD_E=0;

        dellay(1000);

        LCD_E=1;

        }

        voidlcd_init(void)

        {

        LCD_DATA=0;

        WriteCommandLcd(0x38);

        dellay(1000);

        WriteCommandLcd(0x38);

        dellay(1000);

        WriteCommandLcd(0x01);

        WriteCommandLcd(0x0c);

        }

        voiddisplay_xy(unsignedcharx,unsignedchary)

        {

        if(y==1)

        x+=0x40;

        x+=0x80;

        WriteCommandLcd(x);

        }

        voiddisplay_string(unsignedcharx,unsignedchary,unsignedchar*s)

        {

        display_xy(x,y);

        while(*s)

        {

        WriteDataLcd(*s);

        s++;

        }

        }

        voidWrite_CGRAM(unsignedcharadd,unsignedchar*char_num)

        {

        unsignedi;

        add=add<<3;

        WriteCommandLcd(0x40|add+8);

        for(i=0;i<8;i++)

        {

        WriteDataLcd(*char_num++);

        }

        }

        voiddelayms()

        {

        inti;

        for(i=110;i>0;i--);

        }

        voiddelay1s()

        {

        inti,j;

        for(i=1000;i>0;i--);

        for(j=110;j>0;j--);

        }

        voidconvert()

        {

        unsignedlongvalue;

        chari;

        unsignedlongres;

        inttemp,temp2;

        intw;

        P1=0xff;

        ADC_RD=0;

        for(i=0;i<10;i++);

        value=P1;

        res=(float)(2550000+110000*value/30)/(2550-11*value/30);

        temp=(float)(res*10000-10000000)/3851-545;

        temp2=temp;

        if(temp>=0)

        {

        for(i=6;temp>0;i--)

        {

        LcdBuf1[i]=temp%10+48;

        temp/=10;

        }

        }

        if(temp<0)

        {

        w=-temp;

        for(i=6;w>0;i--)

        {

        LcdBuf1[i]=w%10+48;

        w/=10;

        }

        }

        if(i>=0&&temp<0)

        {

        if(temp>-10)

        {

        LcdBuf1[i]=0;

        i--;

        }

        LcdBuf1[i]=-;

        i--;

        /* if(i==5)

        {

        LcdBuf1[5]=0;

        i--;

        }

        LcdBuf1[4]=-;

        i--; */

        }

        for(;i>=0;i--)

        LcdBuf1[i]=;

        for(i=0;i<5;i++)

        LcdBuf1[i]=LcdBuf1[i+1];

        if(LcdBuf1[4]==)LcdBuf1[4]=0;

        LcdBuf1[5]=.;

        LcdBuf1[7]=1;

        LcdBuf1[8]=C;

        WriteCommandLcd(0x84);

        display_string(3,0,LcdBuf1);

        ADC_RD=1;

        ADC_WR=0;

        for(i=0;i<10;i++)

        ADC_WR=1;

        delayms();

        }

        main()

        {

        unsignedchari;

        lcd_init();

        for(i=0;i<2;i++)

        Write_CGRAM(i,Bmp001[i]);

        ADC_CS=0;

        ADC_WR=0;

        for(i=0;i<10;i++);

        ADC_WR=1;

        while(1)

        {

        convert();

        delay1s();

        }

        }



        關(guān)鍵詞: pt100測溫程序LCD160

        評論


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

        關(guān)閉
        主站蜘蛛池模板: 江油市| 岳普湖县| 南部县| 柯坪县| 石家庄市| 丹巴县| 东至县| 张家界市| 新竹县| 霍林郭勒市| 司法| 武邑县| 多伦县| 泉州市| 龙口市| 湖口县| 滨州市| 阿荣旗| 方正县| 宣武区| 德钦县| 蕲春县| 泗阳县| 土默特右旗| 桑植县| 收藏| 年辖:市辖区| 英德市| 寿阳县| 湘潭县| 临西县| 江永县| 喀什市| 平泉县| 胶州市| 嵊泗县| 富宁县| 芦山县| 特克斯县| 上林县| 汉源县|