標(biāo)題:
基于單片機(jī)的智能飲水機(jī)的壓力模塊程序
[打印本頁]
作者:
wiselee
時(shí)間:
2021-6-11 15:57
標(biāo)題:
基于單片機(jī)的智能飲水機(jī)的壓力模塊程序
詳情見附件!
單片機(jī)源程序如下:
#include "config.h"
sbit DT = P0 ^ 7;
sbit SCK = P0 ^ 6;
#define DT_HIGH DT=1
#define DT_LOW DT=0
#define SCK_HIGH SCK=1
#define SCK_LOW SCK=0
unsigned long ReadCount(void)
{
unsigned long Count=0;
unsigned char i;
DT_HIGH;
SCK_LOW; //使能AD
while(DT); //AD轉(zhuǎn)換等待
for (i=0;i<24;i++)
{
SCK_HIGH; //put down SCK 置高(發(fā)送脈沖)
Count = Count << 1; //下降沿來時(shí)變量count左移一位
SCK_LOW ; //PD SSCK 置低
if(DT) Count++;
}
SCK_HIGH;
Count = Count ^ 0x800000; //第25個(gè)脈沖下降沿來時(shí),轉(zhuǎn)換數(shù)據(jù)
SCK_LOW ;
return(Count);
}
復(fù)制代碼
#include "config.h"
void main()
{
float Date ;
UartInit() ;
while(1)
{
Date = ReadCount() ;
Date = (unsigned int)((float)Date/4.35+0.05);
UART_SendStr("The press is ") ;
UART_SendStrNum(Date);
}
}
復(fù)制代碼
以上程序51hei提供下載:
壓力傳感器檢測(cè)是否有杯子放入.zip
(46.92 KB, 下載次數(shù): 9)
2021-6-11 15:57 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
需要 stc15頭文件才能編譯
http://www.torrancerestoration.com/bbs/dpj-117121-1.html
作者:
51hei團(tuán)團(tuán)
時(shí)間:
2021-6-11 16:34
么有原理圖啊 原理圖能分享一下嗎?
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1