/*
Mess Feedback and Leftover Monitoring System
--------------------------------------------
Project Description:
This project collects feedback on meals served in a college mess, measures leftover food, and prevents multiple feedback submissions for the same meal. The system uses:
1. Pushbuttons for collecting "Liked", "Neutral", and "Disliked" feedback.
2. A slide switch to toggle between active counting mode (ON) and result display mode (OFF).
3.Two HX711 modules with load cells are used: one to measure the weight of leftover food and the other to measure the weight of the plate disposal bin.
Working:
1. Switch ON:
- The system counts button presses for each feedback type.
- The LCD displays live feedback counts.
- A weight sensor detects when a used plate is placed on the disposal bin. If the weight changes (indicating new feedback entry), the system disregards inputs until the weight stabilizes. - Feedback is allowed only once per change in the weight reading.
2. Switch OFF:
- The LCD displays the final feedback counts.
- The system measures and displays the leftover food weight.
- After displaying the results, the system resets and prepares for a new session.
Components:
- Arduino UNO, 16x2 LCD with I2C, Pushbuttons, HX711 Load Cell Amplifier, Slide Switch, Resistors.
Author: ANBURAJ P
Roll Number: CB.EN.U4ECE23205
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "HX711.h"
// Pin Definitions
#define SWITCH_PIN 8 // Slide switch pin
#define BTN1_PIN 11 // Button for Like
#define BTN2_PIN 10 // Button for Neutral
#define BTN3_PIN 9 // Button for Dislike
#define HX711_DT 7 // HX711 data pin for leftovers
#define HX711_SCK 6 // HX711 clock pin for leftovers
#define HX711_DT_PLATE 5 // HX711 data pin for plate sensor
#define HX711_SCK_PLATE 4 // HX711 clock pin for plate sensor
// Initialize LCD
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Initialize HX711 instances
HX711 scaleLeftover;
HX711 scalePlate;
// Button Counters
int btn1Count = 0; // Like
int btn2Count = 0; // Neutral
int btn3Count = 0; // Dislike
// Plate State
float previousPlateWeight = 0.0;
float currentPlateWeight = 0.0;
bool plateChanged = false;
void setup() {
// Pin Modes
pinMode(SWITCH_PIN, INPUT_PULLUP); // Slide switch
pinMode(BTN1_PIN, INPUT);
pinMode(BTN2_PIN, INPUT);
pinMode(BTN3_PIN, INPUT);
// Initialize LCD
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Initializing...");
delay(2000);
lcd.clear();
// Initialize HX711 for Leftovers
scaleLeftover.begin(HX711_DT, HX711_SCK); // initialize scaleLeftover
// Initialize HX711 for Plate
scalePlate.begin(HX711_DT_PLATE, HX711_SCK_PLATE);
scalePlate.set_scale(2280.f); // Set calibration factor for plates
scalePlate.tare(); // Tare the scale
lcd.print("System Ready!");
delay(2000);
lcd.clear();
}
void loop() {
// Read the slide switch state
bool switchState = digitalRead(SWITCH_PIN); // HIGH = ON, LOW = OFF
// Read plate weight
currentPlateWeight = scalePlate.get_units();
plateChanged = (abs(currentPlateWeight - previousPlateWeight) > 0.1); // Detect significant plate change
if (switchState == HIGH) {
// Counting Mode
lcd.setCursor(0, 0);
lcd.print("Counting Mode ");
lcd.setCursor(0, 1);
lcd.print("Like:");
lcd.print(btn1Count);
lcd.print(" Neutral:");
lcd.print(btn2Count);
lcd.print(" Dislike:");
lcd.print(btn3Count);
if (plateChanged) {
// Register button presses only if plate weight changes
if (digitalRead(BTN1_PIN) == HIGH) {
btn1Count++;
previousPlateWeight = currentPlateWeight; // Update plate weight
}
if (digitalRead(BTN2_PIN) == HIGH) {
btn2Count++;
previousPlateWeight = currentPlateWeight; // Update plate weight
}
if (digitalRead(BTN3_PIN) == HIGH) {
btn3Count++;
previousPlateWeight = currentPlateWeight; // Update plate weight
}
}
} else {
// Slide Switch OFF - Display Final Results
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Final Results:");
lcd.setCursor(0, 1);
lcd.print("Like:");
lcd.print(btn1Count);
lcd.print(" Neutral:");
lcd.print(btn2Count);
lcd.print(" Dislike:");
lcd.print(btn3Count);
delay(3000); // Show results for 5 seconds
// Display leftover weight
lcd.clear();
if (scaleLeftover.is_ready()) {
float leftoverWeight = scaleLeftover.get_units(); // Get the leftover weight
leftoverWeight *= 2.381; // Apply a multiplication factor to get weight in grams
if (leftoverWeight < 0) leftoverWeight = 0; // Prevent negative weight
lcd.setCursor(0, 0);
lcd.print("Leftovers:");
lcd.setCursor(0, 1);
lcd.print(leftoverWeight/1000, 2);
lcd.print(" kg");
} else {
lcd.setCursor(0, 0);
lcd.print("HX711 Error");
}
delay(5000); // Show leftover weight for 5 seconds
btn1Count = 0;
btn2Count = 0;
btn3Count = 0;
}
}