标题:
基于单片机的智能饮水机的压力模块程序
[打印本页]
作者:
wiselee
时间:
2021-6-11 15:57
标题:
基于单片机的智能饮水机的压力模块程序
详情见附件!
单片机源程序如下:
#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转换等待
for (i=0;i<24;i++)
{
SCK_HIGH; //put down SCK 置高(发送脉冲)
Count = Count << 1; //下降沿来时变量count左移一位
SCK_LOW ; //PD SSCK 置低
if(DT) Count++;
}
SCK_HIGH;
Count = Count ^ 0x800000; //第25个脉冲下降沿来时,转换数据
SCK_LOW ;
return(Count);
}
复制代码
#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);
}
}
复制代码
以上程序51hei提供下载:
压力传感器检测是否有杯子放入.zip
(46.92 KB, 下载次数: 9)
2021-6-11 15:57 上传
点击文件名下载附件
下载积分: 黑币 -5
需要 stc15头文件才能编译
http://www.51hei.com/bbs/dpj-117121-1.html
作者:
51hei团团
时间:
2021-6-11 16:34
么有原理图啊 原理图能分享一下吗?
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1