Hello Everyone,
I am looking for some help on a project I have. What I am trying to make is a Co2 filling machine. I have a UNO board that I am working with. What I am trying to do is place a co2 bottle on a scale and press a button to fill the bottle to a set weight weight. Example would be a 5 or 10 pound fill. I have the load cells working and calibrated currently. My problem is when I press my button to run the fill sequence. I cannot get it to close the valve once the weight has been reached. Could someone look at my code and offer suggestions.
#include "HX711.h"
#define DOUT 3
#define CLK 2
#define MANUAL 10 //manual fill button
#define FIVE 9 // 5LB fill
#define TEN 8 // 10LB fill
#define TWENTY 7 // 20LB Fill
#define RST 11 // Tare weight
#define FILL 13 // Fill Valve
float seed = -9560.00;
HX711 scale(DOUT, CLK);
///////////////////////////////////////////////////////////////////////////////////
void setup() {
// put your setup code here, to run once:
pinMode(MANUAL, INPUT_PULLUP); // Manual fill open air valve
pinMode(FIVE, INPUT_PULLUP); //
pinMode(TEN, INPUT);
pinMode(TWENTY, INPUT);
pinMode(RST, INPUT_PULLUP); // reset scale to 0
pinMode(FILL, OUTPUT);
Serial.begin(9600);
scale.set_scale(seed);
scale.tare(); //Reset Scale to 0
}
///////////////////////////////////////////////////////////////////////////////////
void loop() {
float weight = scale.get_units(10);
int RSTRequest =digitalRead(RST);
int FIVERequest = digitalRead(FIVE);
//-------------------------------TARE------------------------------
scale.set_scale(seed);
Serial.print("\tPounds:\t");
Serial.println(scale.get_units(10), 1);
if (RSTRequest == LOW) {
Serial.println("Resetting to zero");
scale.tare();
}
//-------------------------END TARE------------------------
//---------------------5LB Fill------------------------
{if ((FIVERequest == LOW) &&(weight < 5))
Serial.println("5 Pound Fill");
digitalWrite(FILL, HIGH);
}
}