Powerup
Published

Automatic bottle filling machne using arduino uno

"Arduino-based Automatic Bottle Filling System: IR sensor detects bottles, activates water pump, displays real-time status on a lcd.

BeginnerFull instructions provided5 hours25
Automatic bottle filling machne using arduino uno

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
5v relay module
×1
I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×1
5v buzzer
×1
5v water pump
×1
ir sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit diagram

Code

Code

C/C++
In this arduino ide code i have set the filling time for 16000 which is 16 seconds to fill 500ml bottle you can change the seconds according to your project
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Initialize the library with the I2C address of your LCD (0x27 is a common address, adjust if needed)
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Pin definitions
const int irSensorPin = 7;
const int relayPin = 8;
const int buzzerPin = 9;

// Debounce parameters
const unsigned long debounceDelay = 50;
unsigned long lastDebounceTime = 0;
int lastSensorState = HIGH;
int bottleDetectedState = HIGH;

void setup() {
  // Initialize the LCD
  lcd.init();
  lcd.backlight();
  // Print a message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Place Bottle");

  // Initialize the IR sensor pin as input
  pinMode(irSensorPin, INPUT);

  // Initialize the relay pin as output
  pinMode(relayPin, OUTPUT);

  // Initialize the buzzer pin as output
  pinMode(buzzerPin, OUTPUT);

  // Turn off relay and buzzer initially
  digitalWrite(relayPin, LOW);
  digitalWrite(buzzerPin, LOW);

  delay(2000);  // Display the initial message for 2 seconds
  lcd.clear();
}

void loop() {
  // Read the state of the IR sensor
  int sensorState = digitalRead(irSensorPin);

  // If the sensor state has changed, due to noise or actual detection
  if (sensorState != lastSensorState) {
    lastDebounceTime = millis();
  }

  // If the state change is stable for longer than debounceDelay
  if ((millis() - lastDebounceTime) > debounceDelay) {
    // If the sensor state has changed
    if (sensorState != bottleDetectedState) {
      bottleDetectedState = sensorState;

      // Check if the IR sensor detects an object (assuming LOW when detected)
      if (bottleDetectedState == LOW) {
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Filling......");
        // Turn on the relay to start filling the bottle immediately
        digitalWrite(relayPin, HIGH);
        delay(16000);  // Filling time for 500ml
        // Turn off the relay
        digitalWrite(relayPin, LOW);

        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Filling Complete");

        // Two short beeps to indicate filling is complete
        for (int i = 0; i < 2; i++) {
          digitalWrite(buzzerPin, HIGH);
          delay(200);  // Beep duration
          digitalWrite(buzzerPin, LOW);
          delay(200);  // Pause between beeps
        }

        delay(2000);  // Display the "Filling Complete" message for 2 seconds
        lcd.clear();
      }
    }
  }

  if (bottleDetectedState == HIGH) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Place Bottle");
  }

  lastSensorState = sensorState;
}

Credits

Powerup

Powerup

2 projects • 0 followers

Comments