欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 關(guān)于土壤濕度測(cè)量的程序!學(xué)生黨求助講解!! [打印本頁(yè)]

作者: deiay-    時(shí)間: 2017-12-20 12:50
標(biāo)題: 關(guān)于土壤濕度測(cè)量的程序!學(xué)生黨求助講解!!
#include <reg52.h>
#include <stdio.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int                        // 頭文件及宏定義               
uchar code table[]={
0x28,0x7b,0x1c,0x19,0x4b,
0x89,0x88,0x3b,0x08,0x09
};

sbit DI=P1^3;
sbit DO=P1^3;
sbit CS=P1^1;
sbit CLK=P1^2;
sbit w1=P2^2;
sbit w2=P2^0;
uchar data_f,data_b;
/***********************************************************/
void delay(uint z)
{
        uint x,y;
        for(x=0;x<z;x++)
                for(y=110;y>0;y--);
}
void AD_deal()                                                //0832測(cè)電壓子程序
{
        uchar i;
        DI=1;
        CS=1;
        _nop_();
        CS=0;
        DI=1;
        CLK=1;
        _nop_();_nop_();
        CLK=0;
        _nop_();_nop_();
        CLK=1;
        DI=1;
        _nop_();_nop_();
        CLK=0;
        _nop_();_nop_();
        CLK=1;
        DI=1;          
        _nop_();_nop_();
        CLK=0;
        _nop_();_nop_();
       
        CLK=1;
        _nop_();_nop_();
        CLK=0;
        _nop_();_nop_();
        CLK=1;
       
        for(i=8;i>0;i--)
                {
                data_f|=DO;
                data_f<<=1;
                _nop_();
                CLK=1;
                _nop_();
                _nop_();
                CLK=0;
                _nop_();
                _nop_();       
                }
        for(i=8;i>0;i--)
                {
                data_b<<=1;
                data_b|=DO;
                _nop_();
                CLK=1;
                _nop_();
                _nop_();
                CLK=0;
                _nop_();
                _nop_();
       
                }
        CLK=1;
        _nop_();_nop_();
        CS=1;
}

void display()
{
        int t0,t;
        t0=data_f*1.93/5;
        t=100-t0;
        P0=0xff;
        w1=0;
        P0=table[t/10];
        delay(5);
        w1=1;
       
        P0=0xff;
        w2=0;
        P0=table[t%10];
        delay(5);
        w2=1;
}

void main()                                                                 //主函數(shù)
{


        while(1)       
        {       

                AD_deal();
                display();
        }
}
作者: yesning    時(shí)間: 2017-12-22 14:09
看一看adc0832資料介紹,主要是通過(guò)傳感器阻值變化和模數(shù)轉(zhuǎn)換實(shí)現(xiàn),最近也在做這個(gè)
作者: deiay-    時(shí)間: 2017-12-23 14:18
yesning 發(fā)表于 2017-12-22 14:09
看一看adc0832資料介紹,主要是通過(guò)傳感器阻值變化和模數(shù)轉(zhuǎn)換實(shí)現(xiàn),最近也在做這個(gè)

enen 請(qǐng)問(wèn)程序里怎樣吧輸入的電壓值轉(zhuǎn)換為百分比數(shù)值了?我原理搞懂了一些,但程序有點(diǎn)看不懂,謝謝啦

作者: 21753很難    時(shí)間: 2019-4-14 23:42
樓主搞懂了嗎?那個(gè)w1跟w2是什么啊

作者: 聊聊    時(shí)間: 2021-4-9 17:03
畢設(shè)很難 發(fā)表于 2019-4-14 23:42
樓主搞懂了嗎?那個(gè)w1跟w2是什么啊

不懂





歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1