连接在lcd上的hx711称重传感器上,代码和当前重量的最大重量不变且保持相等



我正在构建一个基于hx711的体重秤,它在LCD上显示测量的重量,以及LCD显示的重量"最大重量";如果重量达到最大,蜂鸣器将发出嗡嗡声。我已经写了代码来执行这些函数,但是,无论如何,权重总是归零,我不能设置最大权重。我将在这里包括一个原理图和代码:

https://i.stack.imgur.com/CC6Jy.jpg

#include "HX711.h"
#include <Wire.h>

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int IN1 = A0;
int IN2 = A1;
int over_val;
int data;
int g_weight;
int Weight;
const int buzzer = 13;

void setup()
{
pinMode(buzzer, OUTPUT);
lcd.init();
lcd.clear();
lcd.backlight();
pinMode(IN1, INPUT);
pinMode(IN2, INPUT);
Init_Hx711();
Serial.begin(9600);
Serial.print("Ready!n");
Get_Maopi();
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Harry Brass ");
lcd.setCursor(0, 1);
lcd.print("  Gus Creech  ");
delay(1000);
lcd.clear();
}
void loop()
{
Weight = Get_Weight();
g_weight = Weight - data;
lcd.setCursor(0, 0);
lcd.print("Weight:");
lcd.print(g_weight);
lcd.print("g    ");
if (digitalRead(IN2) == LOW) {data = Weight;}
if (digitalRead(IN1) == LOW) {over_val = g_weight;
}
if (g_weight <= over_val)
{
lcd.setCursor ( 0, 1 );
lcd.print("Max Weight:");
lcd.print(over_val);
lcd.print("g    ");
digitalWrite(buzzer, LOW);
}
else if (g_weight > over_val)
{
Serial.println("overload");
lcd.setCursor ( 0, 1 );
lcd.print("...OverLoad!!...");
digitalWrite(buzzer, HIGH);
}
delay(50);
}

我会从检查物理连接开始,并尝试运行像这样的简单代码:https://www.instructables.com/Arduino-Scale-With-5kg-Load-Cell-and-HX711-Amplifi/。只是为了确保一切正常。

相关内容

  • 没有找到相关文章

最新更新