Hi i have 2 sets of weighing scales and i can run the code so that it will tell me the weight of the 1st scale for 10 seconds and then it tells me the weight of the second weighing scale for 10 seconds.
is there a way i can use a function on the serial monitor that i can press either 1 or 2 to switch between which weighing scale i want to look at?
Your program will have to read a character from Serial, if one is available and then compare it. If it is a '1' then show scale 1. If it is a '2' then show scale 2. If it is something else (like a carriage return, newline,...) then just ignore it.
Look at the examples in the IDE. File->Examples->Communication->ReadASCIIString
unsigned long time_since_last_reset = 0;
int interval_one = 500;
int interval_two = 500;
void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");
scale1.begin(DOUT1, CLK1);
scale1.set_scale(calibration_factor2); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale1.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
Serial.println("Readings1:");
scale2.begin(DOUT2, CLK2);
scale2.set_scale(calibration_factor1); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale2.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
Serial.println("Readings2:");
}
void loop() {
scale1.begin(DOUT1, CLK1);
{
time_since_last_reset = millis();
while((millis() - time_since_last_reset) < interval_one){
Serial.print("Warehouse Reading:");
Serial.print(scale1.get_units(), 4); //scale.get_units() returns a float
Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
}
scale2.begin(DOUT2, CLK2);
time_since_last_reset = millis();
while((millis() - time_since_last_reset) < interval_two){
Serial.print("Shop floor Reading:");
Serial.print(scale2.get_units(), 4); //scale.get_units() returns a float
Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();}
sorry still dont understand after looking at the example.
Yes i want to be able to press 1 in the serial monitor to view scale 1 or
i want to be able to press 2 in serial monitor to view 2. but what function would i use to make it do that?