Help call Procedure and return back

Dear all, I learning the code from :http://www.instructables.com/id/Arduino-Scale-With-5kg-Load-Cell-and-HX711-Amplifi/ 1/Main program is scale from loadcell and Hx711. 2/Procudure Calibrate loadcell. Please show me how to run the Main program and when I need, I call procudure Calibrate. Thanks for help. Reed Noel

Dear all,
I learning the code from :http://www.instructables.com/id/Arduino-Scale-With-5kg-Load-Cell-and-HX711-Amplifi/
1/Main program is scale from loadcell and Hx711.
2/Procudure Calibrate loadcell.
Please show me how to run the Main program and when I need, I call procudure Calibrate.
Thanks for help.
Reed Noel

HX711.zip (2.79 KB)

Disclaimer: No experience with the load cell.

Possibly something like 1) Take the two scale methods out of setup() and place them in their own function called calibrate()

void calibrate()
{
  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
}

2) In loop(), if a condition is true, call the calibrate() function

Do you want to use a button, a serial command or ... ?

sterretje: Disclaimer: No experience with the load cell.

Possibly something like 1) Take the two scale methods out of setup() and place them in their own function called calibrate()

void calibrate()
{
  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
}

2) In loop(), if a condition is true, call the calibrate() function

Do you want to use a button, a serial command or ... ? Dear, I want using botton for call Calib procedure, and button as calib, I using 4 botton already, but it don't run. sorry, I missing attach file

Threads merged.

[quote author=Coding Badly link=msg=3655596 date=1521524040] Threads merged.

[/quote] Thanks Mod

Read up on how to use buttons. So if you press a specific one, the calibrate() function is called.

Dear sterretje, if can going to procedure ( have some button as calib) can using button for changing number, and can't return the loop()

How do you mean, can't return the loop()?

Simple framework below

void loop()
{
  if (button went from not pressed to pressed)
  {
    calibrate();
  }
  else
  {
    // measure
  }
}

sterretje: How do you mean, can't return the loop()?

Simple framework below

void loop()
{
  if (button went from not pressed to pressed)
  {
    calibrate();
  }
  else
  {
    // measure
  }
}

@sterretje, I mean that, when inn procedure calibrate(), how to go out ? Thanks

Only you can see procedure calibrate() so only you can possibly know how to end it or get out of it.

In general we're not very good at helping with code we've never seen.

Steve

Read up about functions and the return statement.

That said, with the calibrate function suggested earlier, it will end and return to the point it was called once it has executed the tare call.

slipstick: Only you can see procedure calibrate() so only you can possibly know how to end it or get out of it.

In general we're not very good at helping with code we've never seen.

Steve

the code in the link, I want that, how to put Button in calibbrate() and using it go out the procedure. http://www.instructables.com/id/Arduino-Scale-With-5kg-Load-Cell-and-HX711-Amplifi/

Reednoel4u: the code in the link

Since you're the one asking for help, perhaps you could go to the trouble of copying the code from the web site and posting it here. USE CODE TAGS.

Reednoel4u:
@sterretje,
I mean that, when inn procedure calibrate(), how to go out ?
Thanks

The function that I suggested executes the two statements and next returns to loop().

Have you tried to use it? If so, what was the result?

If it did not work as expected, post your code and explain what you think it should do.

That page you linked to contains a separate calibration program. If you want to make it a function within another program then YOU need to do the work to convert it to a function.

When you've done that, if you have problems post the complete program here and we'll help you get it working.

Steve