新聞中心

        Nokia 5110_DS18B20顯示程序

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

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

        /**********Nokia 5110 LCD 顯示程序***************/
        /**********作者:鄭文 ***************/
        /**********芯片:AT89S52 **************/
        /*功能:支持中文顯示、字符顯示、圖片顯示********/
        #include
        #include
        #include "english_6x8_pixel.h"
        #include "picture84x48.h"
        #include "Nokia_5110.h"
        #include "18b20.h"

        #define uchar unsigned char
        #define uint unsigned int

        uchar tem_h,tem_l,tem_f,tem_f1,tem_f2;
        uint tem; //溫度讀取后*10后存儲(chǔ)空間地址
        float tem_read; //溫度讀取保存地址空間

        void Delay1ms(unsigned int count);
        void temperature_read_charge(void);
        void nokia_5110_picture();//寫一屏圖


        /************毫秒延時(shí)程序********************/
        void Delay1ms(unsigned int count)
        {
        unsigned int i,j;
        for(i=0;ifor(j=0;j<120;j++);
        }
        /********************************************/
        /*void temperature_read_charge(void)
        {

        tem_read=ReadTemperature();
        tem=tem_read*1000; //溫度精確到小數(shù)點(diǎn)后3位
        tem_h=tem/10000+0x30; //溫度高位
        tem_l=( tem-(tem_h-0x30)*10000 )/1000+0x30; //溫度低位
        tem_f=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000 )/100+0x30;
        tem_f1=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000-(tem_f-0x30)*100 )/10+0x30;
        tem_f2=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000-(tem_f-0x30)*100-(tem_f1-0x30)*10 )+0x30;
        Delay1ms(100);
        }
        */


        /**********************************************/
        void nokia_5110_picture()//寫一屏圖
        {
        uchar e;
        uchar t;
        uchar k;
        uint d;
        d=0;
        for(t=0;t<6;t++)
        {
        for(k=0;k<84;k++)
        {
        e=dal[d];
        write_byte(e,1);
        d=d+1;
        }
        }
        }
        /**************************************/

        /*****************主程序********************/
        void main(void)
        {
        unsigned main_i,x,y;
        unsigned xnum ,ynum;
        float T_temp;
        uchar i;
        uchar moni_temp;

        P2=0X00;
        LED_A =1;
        LCD_VDD =1;
        LCD_GND =0;
        LCD_Init(); //初始化液晶
        LCD_Clear();


        /***********指定地址顯示漢字(x,y,table)*********************/

        /***********取點(diǎn)(x,y,byte數(shù)據(jù))*************/
        /*其中X=[0,83] Y=[0,5] byte 顯示是從下到上 */

        nokia_5110_picture();
        LCD_set_XY(42,3);
        LCD_write_char(124);
        LCD_write_char(C);


        /*while(1)
        {
        for(i=0;i<8;i++)
        {
        LCD_set_XY(68,4);
        LCD_write_char(125+i);
        Delay1ms(100);
        }
        for(i=0;i<8;i++)
        {
        LCD_set_XY(68,3);
        LCD_write_char(125+i);
        Delay1ms(100);
        }
        for(i=0;i<8;i++)
        {
        LCD_set_XY(68,2);
        LCD_write_char(125+i);
        Delay1ms(100);
        }
        for(i=0;i<8;i++)
        {
        LCD_set_XY(68,1);
        LCD_write_char(125+i);
        Delay1ms(100);
        }
        for(i=0;i<8;i++)
        {
        LCD_set_XY(68,0);
        LCD_write_char(125+i);
        Delay1ms(100);
        }

        LCD_set_XY(68,0);
        LCD_write_char(125);
        LCD_set_XY(68,1);
        LCD_write_char(125);
        LCD_set_XY(68,2);
        LCD_write_char(125);
        LCD_set_XY(68,3);
        LCD_write_char(125);
        LCD_set_XY(68,4);
        LCD_write_char(125);

        }*/

        while(1)
        {
        /********溫度數(shù)據(jù)的讀取和轉(zhuǎn)換*************/
        tem_read=ReadTemperature();
        tem=tem_read*1000; //溫度精確到小數(shù)點(diǎn)后一位08.1.8
        tem_h=tem/10000+0x30; //溫度高位
        tem_l=( tem-(tem_h-0x30)*10000 )/1000+0x30; //溫度低位
        tem_f=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000 )/100+0x30;
        tem_f1=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000-(tem_f-0x30)*100 )/10+0x30;
        tem_f2=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000-(tem_f-0x30)*100-(tem_f1-0x30)*10 )+0x30;

        //Delay1ms(5);
        LCD_set_XY(12,3);
        LCD_write_char(tem_h);
        // Delay1ms(5);
        LCD_write_char(tem_l);
        // Delay1ms(5);
        LCD_write_char(.);
        // Delay1ms(5);
        LCD_write_char(tem_f);
        // Delay1ms(5);
        LCD_write_char(tem_f1);
        //Delay1ms(5);

        moni_temp=((tem_h-0x30)*10+tem_l-0x30)+1;//加1是修正值

        if(moni_temp>0 && moni_temp<8)
        {


        LCD_set_XY(68,3);
        LCD_write_char(125);
        LCD_set_XY(68,2);
        LCD_write_char(125);
        LCD_set_XY(68,1);
        LCD_write_char(125);
        LCD_set_XY(68,0);
        LCD_write_char(125);

        LCD_set_XY(68,4);
        LCD_write_char(125+moni_temp);
        }
        else if(moni_temp>=8 && moni_temp<16)
        {
        LCD_set_XY(68,2);
        LCD_write_char(125);
        LCD_set_XY(68,1);
        LCD_write_char(125);
        LCD_set_XY(68,0);
        LCD_write_char(125);

        LCD_set_XY(68,4);
        LCD_write_char(132);
        LCD_set_XY(68,3);
        LCD_write_char(125+moni_temp-8);
        }
        else if(moni_temp>=16 && moni_temp<24)
        {
        LCD_set_XY(68,1);
        LCD_write_char(125);
        LCD_set_XY(68,0);
        LCD_write_char(125);

        LCD_set_XY(68,4);
        LCD_write_char(132);
        LCD_set_XY(68,3);
        LCD_write_char(132);
        LCD_set_XY(68,2);
        LCD_write_char(125+moni_temp-16);
        }
        else if(moni_temp>=24 && moni_temp<32)
        {
        LCD_set_XY(68,0);
        LCD_write_char(125);

        LCD_set_XY(68,4);
        LCD_write_char(132);
        LCD_set_XY(68,3);
        LCD_write_char(132);
        LCD_set_XY(68,2);
        LCD_write_char(132);

        LCD_set_XY(68,1);
        LCD_write_char(125+moni_temp-24);
        }
        else if(moni_temp>=32 && moni_temp<40)
        {
        LCD_set_XY(68,4);
        LCD_write_char(132);
        LCD_set_XY(68,3);
        LCD_write_char(132);
        LCD_set_XY(68,2);
        LCD_write_char(132);
        LCD_set_XY(68,1);
        LCD_write_char(132);

        LCD_set_XY(68,0);
        LCD_write_char(125+moni_temp-32);
        }
        else
        {;}

        }

        }



        關(guān)鍵詞: Nokia5110DS18B20顯示程

        評(píng)論


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

        關(guān)閉
        主站蜘蛛池模板: 阳泉市| 武宣县| 镇远县| 宿迁市| 马关县| 东辽县| 乌拉特后旗| 黑龙江省| 哈密市| 来凤县| 治县。| 泾阳县| 平凉市| 四平市| 光山县| 固始县| 伊川县| 松原市| 偃师市| 临海市| 永州市| 沁阳市| 扶绥县| 池州市| 健康| 大兴区| 彰化县| 房山区| 息烽县| 汝阳县| 临邑县| 和静县| 都匀市| 文水县| 察雅县| 桐乡市| 汝南县| 花垣县| 青海省| 大田县| 余江县|