#include "HX711.h" const int LOADCELL_DOUT_PIN = 2; const int LOADCELL_SCK_PIN = 3; HX711 scale; void setup() { Serial.begin(9600); scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); pinMode(4, OUTPUT); } void loop() { if (scale.is_ready()) { long reading = scale.read(); Serial.print("HX711 reading: "); Serial.println(reading); } else { Serial.println("HX711 not found."); }
if (reading <= 30000){ digitalWrite(4, HIGH); } delay(1000); }
I would like to output according to the weight sensor value in the last if statement
When you run that programming
I get an error saying'reading' was not declared in this scope. I know what the error itself means,
I'm not sure how to fix it. And I want to give at least 6 output values. To solve that error, reading is the value that is read. Will it be solved by putting reading in any variable? I'm curious about the solution
if (scale.is_ready())(
long reading = scale.read();
This error occurred because a variable was declared in the if statement.
long reading;
if (scale.is_ready())(
reading = scale.read();
Just declare the variable above the if statement.