資源簡介
庫文件 親測 可用 簡單功能 還有說明文當(dāng)
提醒大家 網(wǎng)絡(luò)很多HX711說明命令有些混亂
代碼片段和文件信息
#include?“HX711.h“
#include?“Arduino.h“
//int?DOUT;//定義數(shù)據(jù)引腳
//int?SCK;//定義時(shí)鐘引腳
//float?scale;//定義比例系數(shù)
//long?offset;//定義補(bǔ)償值
//int?times;//定義采集次數(shù)
Hx711::Hx711(int?IO_DOUTint?IO_SCK)//構(gòu)造函數(shù)
{
DOUT?=?IO_DOUT;
SCK?=?IO_SCK;
pinMode(SCK?OUTPUT);//設(shè)置IO口工作方式
pinMode(DOUT?INPUT);
}
void?Hx711::setScale(float?IO_scale)//設(shè)置比例系數(shù)
{
scale?=?IO_scale;
}
void?Hx711::setOffset(long?IO_offset)//設(shè)置補(bǔ)償值
{
offset?=?IO_offset;
}
long?Hx711::getValue()//采集一次ADC值
{
unsigned?long?Count;
unsigned?char?i;
digitalWrite(SCKLOW);
Count?=?0;
while(digitalRead(DOUT)?==?1);//低電平時(shí)數(shù)據(jù)可以輸出
for(i=0;i<24;i++)//循環(huán)讀取數(shù)據(jù)
{
digitalWrite(SCKHIGH);
Count?=?Count<<1;
digitalWrite(SCKLOW);
if(digitalRead(DOUT)?==?1)?Count++;//最低位置1
}
digitalWrite(SCKHIGH);
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-05-21?15:37??HX711\
?????目錄???????????0??2013-05-21?15:37??HX711\examples\
?????目錄???????????0??2013-06-17?09:10??HX711\examples\weighting\
?????文件???????27648??2013-06-17?09:09??HX711\examples\weighting\weighting.doc
?????文件?????????554??2013-04-16?19:06??HX711\examples\weighting\weighting.ino
?????文件????????1284??2013-05-21?15:36??HX711\HX711.cpp
?????文件?????????488??2013-04-16?18:51??HX711\HX711.h
?????文件?????????118??2013-04-16?18:45??HX711\keywords.txt
評論
共有 條評論