/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: "Gas Cylinder Tracker"
- Source Code compiled for: Arduino Uno
- Source Code created on: 2024-03-15 11:15:56
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Measuring net weight of a full gas cylinder, */
/* determining the reference weight of gas in the */
/* cylinder by subtracting the weight of an empty gas */
/* cylinder from the net weight of a full gas */
/* cylinder, display the reference weight on the Lcd */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Measuring net weight of a full gas cylinder, */
/* determining the reference weight of gas in the */
/* cylinder by subtracting the weight of an empty gas */
/* cylinder from the net weight of a full gas */
/* cylinder, display the reference weight on the LCD */
/****** END SYSTEM REQUIREMENTS *****/
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void displayReferenceWeight(float referenceWeight);
/***** DEFINITION OF I2C PINS *****/
const uint8_t Mybutton_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
const uint8_t Mybutton_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
const uint8_t Mybutton_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27; // Address of the LCD module
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
LiquidCrystal_I2C lcd(Mybutton_LCD1602I2C_I2C_SLAVE_ADDRESS, 20, 4);
void setup()
{
lcd.begin(20, 4); // Initialize the LCD with 20 characters and 4 lines
lcd.backlight();
Serial.begin(9600); // Initialize the Serial communication
}
void loop()
{
if (Serial.available())
{
// Read the serial input and calculate the reference weight
String inputString = Serial.readStringUntil('\n');
float netWeight = inputString.toFloat();
float emptyCylinderWeight = 10.0; // Placeholder for the weight of an empty gas cylinder
float referenceWeight = netWeight - emptyCylinderWeight;
// Display the reference weight on the LCD
displayReferenceWeight(referenceWeight);
}
}
void displayReferenceWeight(float referenceWeight)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Reference Weight:");
lcd.setCursor(0, 1);
lcd.print(referenceWeight, 2);
lcd.print(" kg");
}