My first post, so I won’t be offended if you correct how I am asking or tell me what I am leaving out in order to help me figure out my problem.
I have two separate programs running on two different Arduino Uno units.
The first has a serial 16x2 display, a load cell, HX711 and is calibrated for what I am measuring with it. It is to be a sorting machine where I can place a “standard” that is in the middle of the weight range of what I am wanting to sort on the load cell and power up/reset the Uno and tare the unit. At that point subsequent objects placed on the load cell are + or - the standard and that is displayed on the LCD. This is the code for that part.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
LiquidCrystal_I2C lcd(0x3f,16,2);
#include "HX711.h"
#define calibration_factor -425.0
#define DOUT 3
#define CLK 2
int potpin = 2;
int val;
HX711 scale(DOUT, CLK);
void setup() {
lcd.init();
lcd.backlight();
Serial.begin(9600);
Serial.println("HX711 scale");
scale.set_scale(calibration_factor);
scale.tare(); //"center of target" weight on the scale at start up, resets the scale to 0
Serial.println("Readings:");
}
void loop() {
Serial.print("Reading: ");
Serial.print(scale.get_units(), 2);
Serial.println();
val = analogRead("Reading: ");
val = map(val, 0, 1023, 5, 175);
// Pos = map(val, 0, 1023, 0, 180);
lcd.setCursor(0,0);
lcd.print("Weight: ");
lcd.print(scale.get_units(), 1);
lcd.print("gn ");
lcd.println();
lcd.print(val);
}
The other Uno I have setup with the same display, a 10k POT that is controlling a servo. It is calibrated to swing the servo throughout its range as the POT is rotated throughout its range and display the degrees of servo rotation. This is the code for that part.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
LiquidCrystal_I2C lcd(0x3f,16,2);
Servo myservo;
int potpin = 0;
int val;
void setup()
{
myservo.attach(9);
lcd.init();
lcd.backlight();
lcd.setCursor(3,0);
myservo.write(0);
}
void loop()
{
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);
// Pos = map(val, 0, 1023, 0, 180);
myservo.write(val);
lcd.setCursor(1,0);
lcd.print(" ");
lcd.setCursor(1,0);
lcd.print(val);
lcd.setCursor(5,0);
lcd.print("Degrees Arc");
lcd.setCursor(2,1);
delay(15);
}
Where I have seemed to “hit the wall” is joining the two together so the zeroed object on the scale sets the servo at 90 degrees. Objects over the weight on the cell when “zeroed” with the “standard” swing the servo one direction, while objects under the “standard” swing the servo in the opposite direction.
I have read a lot, watched a number of videos, read a lot more, watched some other videos and will continue but I feel I am missing some key words in my searches because I haven’t found what I am looking for.
I also understand that the two programs are not going to be directly compatible as the inputs are not the same. I just made the two examples as “baby steps” in figuring out how to calibrate the load cell to do what I wanted and get the servo to react the way I wanted. Figured I would crawl first then try and walk.
I hope it’s not too drawn out of a post and I can attach photos of the hardware/wiring but they are not a problem because that part works.
Thanks in advance for any help in pointing me in the right direction.