I'm new to Arduino, I'm writing a sketch to display the weight on load cell on LCD,
this is my sketch:
#include "HX711.h"
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define calibration_factor -428//This value is obtained using the SparkFun_HX711_Calibration sketch
#define LOADCELL_DOUT_PIN 3
#define LOADCELL_SCK_PIN 2
HX711 scale;
void setup() {
lcd.begin(16,2);
lcd.println("HX711 scale demo");
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
lcd.println("Readings:");
}
void loop() {
lcd.print("Reading: ");
lcd.print(scale.get_units(), 1);
lcd.print(" g");//You can change this to kg but you'll need to refactor the calibration_factor
lcd.println();
}
After I upload this sketch, it displays the "HX711 scale demo " correctly but after that, all I get is some gibberish values on the screen.
I'm using Arduino nano and have connected the pins as the described in the sketch.
Can somebody help me with the sketch?