资源简介
上电显示----
上电去皮
显示数据 在重物移除后 保持2.5s显示时间;
代码片段和文件信息
#include “HX711.h“
#include
HX711::HX711(byte dout byte pd_sck byte gain) {
PD_SCK = pd_sck;
DOUT = dout;
pinMode(PD_SCK OUTPUT);
pinMode(DOUT INPUT);
set_gain(gain);
}
HX711::~HX711() {
}
//static
bool HX711::is_ready() {
return digitalRead(DOUT) == LOW;
}
void HX711::set_gain(byte gain) {
switch (gain) {
case 128: // channel A gain factor 128
GAIN = 1;
break;
case 64: // channel A gain factor 64
GAIN = 3;
break;
case 32: // channel B gain factor 32
GAIN = 2;
break;
}
digitalWrite(PD_SCK LOW);
read();
}
long HX711::read() {
// wait for the chip to become ready
while (!is_ready());
byte data[3];
// pulse the clock pin 24 times to read the data
for (byte j = 3; j--;) {
for (char i = 8; i--;) {
digitalWrite(PD_SCK HIGH);
bitWrite(data[j] i digitalRead(DOUT));
digitalWrite(PD_SCK LOW);
}
}
// set the channel and the gain factor for the next reading using the clock pin
for (int i = 0; i < GAIN; i++) {
digitalWrite(PD_SCK HIGH);
digitalWrite(PD_SCK LOW);
}
data[2] ^= 0x80;
return ((uint32_t) data[2] << 16) | ((uint32_t) data[1] << 8) | (uint32_t) data[0];
}
long HX711::read_average(byte times) {
long sum = 0;
for (byte i = 0; i < times; i++) {
sum += read();
}
return sum / times;
}
double HX711::get_value(byte times) {
return read_average(times) - OFFSET;
}
float HX711::get_units(byte times) {
return get_value(times) / SCALE;
}
void HX711::tare(byte times) {
double sum = read_average(times);
set_offset(sum);
}
void HX711::set_scale(float scale) {
SCALE = scale;
}
void HX711::set_offset(long offset) {
OFFSET = offset;
}
void HX711::power_down() {
digitalWrite(PD_SCK LOW);
digitalWrite(PD_SCK HIGH);
}
void HX711::power_up() {
digitalWrite(PD_SCK LOW);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1812 2019-03-12 23:19 WeightScale\HX711.cpp
文件 2295 2019-03-12 23:19 WeightScale\HX711.h
文件 5134 2019-03-13 08:53 WeightScale\TM1637.cpp
文件 2264 2019-03-12 23:19 WeightScale\TM1637.h
文件 1991 2019-03-13 08:53 WeightScale\WeightScale.ino
目录 0 2019-03-13 08:57 WeightScale
----------- --------- ---------- ----- ----
13496 6
- 上一篇:丝杆计算软件
- 下一篇:STM32上应用CJSON构造和解析JSON对象
相关资源
- Arduino通过RC522实现开门
- arduino烧录esp8266程序
- arduino通过红外遥控结合蜂鸣器的定时
- arduino mpu6050 dmp库文件
- arduino温湿度采集头文件.rar
- Arduino 步进电机接线方法含有代码
- 四位数码管+DS3231做电子时钟源码.in
- arduino控制57步进电机
- 使用Processing+Arduino写的类似雷达扫描
- arduino上阿里云所需要用到的四个库文
- 基于Arduino的DHT11库文件
- 5Kg电子秤程序LCD1602显示
- Arduino-DHT11温湿度传感器库文件
- ESP8266(arduino)连接阿里云物联网平台
- 电子秤实验报告
- 单片机电子秤重量检测与显示设计
- TCS3200颜色传感器Arduino优化代码快速识
- avrdude-GUI 1.0.5
- arduino程序,用两个红外线传感器来判
- 乐为物联环境监测
- PID巡线,arduino
- 毕业设计论文电子秤很详细
- ArduinoUSBKeyboard库文件
- 寺岗电子秤开发包
- arduino DS3231库
- Arduino串口转发源代码
- arduino+rc522读写卡
- arduino_code.rar
- arduino和ds1302的基于lcd12864闹钟,按键
- 基于51单片机的智能电子秤设计-程序
评论
共有 条评论