Hi, I am in great need of assistance . I am working on a project for my final project . I am creating a device to monitor lpg remaining in a cylinder. I have already tested all the components,and have individual codes i found online and edited .. I will provide as much information as possible.
FIRSTLY LET ME SAY I AM NOT LOOKING FOR SOMEONE TO DO MY PROJECT FOR ME ... but i am very weak in programming . so I am seeking help in fixing my code , and provide any suggestion for future programming ,
with that said . I am using the arduino uno board . and i am using 3 push button for input , i just purchased a 20x4 lcd , but i did all my test on a 1602.. (i can make the lcd changes myself in the code) . my load cell is tested and calibrated .. i have added the code in the header of the code ...
the actual code , i wrote a bunch of stuff based on what i understand , please do not be too judgmental i am a not an expert . there are some notes within the code that i actually need function and codes , but i am still researching how to write it ... so i just use " // then type what should be before them .. please do not erase them but write the code in-front of them ...
/* THIS CODE WORKS !! IT GET ACCURATE READINGS FROM LOAD CELL )
#include "HX711.h"
#define calibration_factor -8360.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define DOUT 3
#define CLK 2
HX711 scale(DOUT, CLK);
void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");
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
Serial.println("Readings:");
}
void loop() {
Serial.print("Reading: ");
Serial.print(scale.get_units(), 1); //scale.get_units() returns a float
Serial.print(" lbs"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
}
1*/
/* This code will be the application for the scale the setup is already done in precious section */
// anolog pin A0,A1 and A3 will be used as digital pin for the input of the push buttons
// anolog pin A0,A1 and A3 is the same as 15,16,and 17
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin[] = {15, 16, 17}; // the number of the pushbutton pins
const int buzzer = 13;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
//configure pinS as input and enable the internal pull-up resistor
void setup() {
// initialize the pushbutton pin as an input:
for (int x = 15; x <= 17; x++)
{
pinMode(buttonPin[x], INPUT); // Keep in mind the pullup means the pushbutton's// logic is inverted. It goes HIGH when it's open,
digitalWrite(buttonPin[x], HIGH)// and LOW when it's pressed
}
}
lcd.clear();
lcd.print(" PLEASE CLEAR SCALE "); //print " PLEASE CLEAR SCALE " ;
lcd.setCursor(0, 1);
lcd.print("PRESS 1 WHEN COMPLEATE"); //print "PRESS 1 WHEN COMPLEATE" ;
//Wait for response;
// When 1 is pressed cLar scale
// read the state of the pushbutton value:
for (int x = 15; x <= 17; x++)
{
buttonState = digitalRead(buttonPin[x]);
// check if the pushbutton is pressed.
// if it is, the buttonState is LOW:
if (buttonState == lOW && buttonPin[x] == 15) {
}
// CLEAR SCALE: FROM CODE ABOVE
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
lcd.clear(); // Clear Screen
lcd.print(" CHOOSE YOUR CYLENDER SIZE"); //print " CHOOSE YOUR CYLENDER SIZE"
lcd.setCursor(0, 1);
lcd.print(" For 25 lbs --> Press 1 "); // print ) " For 25lbs --> Press 1 "
lcd.setCursor(0, 2);
lcd.print(" For 30 lbs --> Press 2 ") // print " For 30lbs --> Press 2
lcd.setCursor(0, 3);
lcd.print(" For 100 lbs --> Press 3 ") // print " For 100lbs --> Press 3 "
// WAIT FOR RESPONSE
// read the state of the pushbutton value:
for (int x = 15; x <= 17; x++)
{
buttonState = digitalRead(buttonPin[x]);
// check if the pushbutton is pressed.
// SETTING MY REFERENCE VALUES
// if it is, the buttonState is LOW:
if (buttonState == LOW && buttonPin[x] == 15) {
// make RefWeigntFull = 48 lbs;
//and RefWeightEmpty = 24 lbs;
}
if (buttonState == LOW && buttonPin[x] == 16) {
//make RefWeigntFull = 61 lbs;
// and RefWeightEmpty = 30 lbs;
}
if (buttonState == LOW && buttonPin[x] == 17) {
//make RefWeigntFull = 169 lbs;
//and RefWeightEmpty = 70 lbs;
}
}
lcd.clear(); // Clear Screen
lcd.print("PLACE CYLENDER ON SCALE"); // Print " PLACE CYLENDER ON SCALE "
lcd.setCursor(0, 1);
lcd.print(" press 1 when compleate ");// Print " press 1 when compleate 1 "
WAIT FOR RESPONSE
// read the state of the pushbutton value:
for (int x = 5; x <= 17; x++)
{
buttonState = digitalRead(buttonPin[x]);
// check if the pushbutton is pressed.
// if it is, the buttonState is LOW:
if (buttonState == LOW && buttonPin[x] == 15) {
// read load cell = scale.get_units(),
// calculation
// ([scale.get_units() / RefWeightFull ] * 100) = PercentageGasLeft
lcd.setCursor(10, 1);
lcd.print(" PercentageGasLeft " & "%");
if (PercentageGasLeft = 20 % ) {
lcd.clear();
lcd.print(" Alert ");
lcd.setCursor(0, 1);
lcd.print(" 20 % gas left ");
digitalWrite(buzzer, LOW);
delay(500);
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
delay(500);
ONCE EVERY 20 MINS ..
}
if (PercentageGasLeft = 10 % ) {
lcd.clear();
lcd.print(" Alert ");
lcd.setCursor(0, 1);
lcd.print(" 10 % gas left ");
digitalWrite(buzzer, LOW);
delay(500);
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
delay(500);
ONCE EVERY 10 MINS ..
}
if (PercentageGasLeft , <= 5 % ) {
lcd.clear();
lcd.print(" CRITICALLY LOW LEVEL ");
lcd.setCursor(0, 1);
lcd.print(" ( PercentageGasLef t) % gas left ");
digitalWrite(buzzer, LOW);
delay(500);
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
delay(500);
ONCE EVERY 5 MINS ..
}
}