Soap/Water Dispenser With IR Sensor

by ultimatediylab in Circuits > Arduino

416 Views, 0 Favorites, 0 Comments

Soap/Water Dispenser With IR Sensor

#7_bb.png

In recent times, the demand for touchless soap dispensers has surged due to a heightened emphasis on hygiene and infection control. Touchless soap dispensers have become a crucial innovation in maintaining sanitation, particularly in public areas, healthcare facilities, and homes. These devices utilize technology such as infrared sensors to automatically dispense soap or sanitizer without requiring direct physical contact.

The primary need for touchless soap dispensers arises from their ability to mitigate the spread of germs and infections. By eliminating the necessity for hand contact, these dispensers significantly reduce the risk of cross-contamination, offering a hygienic solution in shared spaces. Their convenience and efficiency not only promote cleanliness but also encourage regular hand hygiene practices, a critical aspect in preventing the transmission of illnesses. Touchless soap dispensers not only provide ease of use but also contribute to creating a safer and healthier environment for individuals, addressing the current focus on health and well-being.

Supplies

  • Arduino Nano
  • Breadboard
  • Diode
  • Relay Module
  • 5V DC Submersible Pump
  • Jumper Wires
  • IR Sensor

Wiring Instructions:-

  • Connect the VCC and GND pins of the IR sensor to the 5V and GND pins of the Arduino Nano.
  • Connect the signal pin of the IR sensor to a digital pin (e.g., D2) of the Arduino Nano.
  • Connect the VCC and GND pins of the Relay Module to the 5V and GND pins of the Arduino Nano.
  • Connect a digital pin (e.g., D12) of the Arduino Nano to the signal pin of the Relay Module.
  • Wire the submersible pump to the relay module.

Arduino Code:-

// Pin Definitions
const int IR_PIN = 2;      // Pin connected to the IR sensor
const int RELAY_PIN = 12;  // Pin connected to the relay module


// Variables
bool objectDetected = false;


void setup() {
  pinMode(IR_PIN, INPUT);
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, HIGH); // Initially turn off the relay
  
  Serial.begin(9600); // Initialize serial communication for debugging (optional)
}


void loop() {
  // Check if an object is detected by the IR sensor
  if (digitalRead(IR_PIN) == HIGH) {
    if (!objectDetected) {
      objectDetected = true;
      Serial.println("Object Detected! Dispensing Soap...");
      activatePump();
      delay(2000); // Adjust delay time according to pump requirements
    }
  } else {
    objectDetected = false;
  }
}


void activatePump() {
  digitalWrite(RELAY_PIN, LOW); // Turn on the relay
  delay(1000); // Adjust this delay as per your pump requirements
  digitalWrite(RELAY_PIN, HIGH); // Turn off the relay
}



Code Explanation:

  • The code sets up the pins for the IR sensor and the relay module.
  • It continuously checks the IR sensor. When it detects an object (e.g., a hand), it triggers the soap dispensing mechanism through the relay module, which turns on the pump.
  • Adjust timing delays in the code according to the pump's needs for dispensing soap.
  • Ensure the connections are made correctly as per the code.

Please be cautious when dealing with electrical components and ensure the power requirements for the pump are compatible with the relay and the power source. Adjust timings and connections as needed for the specific pump and components you have.

How It Works

how the automatic soap dispenser will work:

  1. Initialization:
  • The Arduino Nano is connected to the various components - the IR sensor, relay module, and submersible pump via a breadboard using jumper wires.
  1. Sensor Detection:
  • The Infrared (IR) sensor constantly checks for the presence of an object (like a hand) within its sensing range.
  1. Detection Trigger:
  • When the IR sensor detects an object in close proximity (e.g., a hand placed under the dispenser), it triggers a signal to the Arduino Nano by changing its state from LOW to HIGH.
  1. Soap Dispensing:
  • Upon detecting the object and the signal change, the Arduino interprets this signal and triggers the soap dispensing mechanism.
  • The Arduino activates the relay module to power the submersible pump used for dispensing soap.
  1. Dispensing Duration:
  • The pump remains active for a predefined duration to dispense a certain amount of soap.
  • After this set time, the pump turns off, concluding the dispensing process.
  1. Reset for Next Dispensing:
  • After the soap dispensing action is completed, the system goes back to the initial state, waiting for the next trigger from the IR sensor.
  1. Safety Measures:
  • The system includes delay periods to ensure appropriate dispensing intervals and to prevent continuous soap flow.
  • The code design prevents re-triggering the dispenser within a specific timeframe to avoid excessive soap discharge or sensor noise triggering.

Keep in mind that the specific timings and distances for sensor activation, as well as the soap dispensing duration, may need adjustments based on the responsiveness of the IR sensor and the flow rate of the pump. These values can be modified in the code to suit the requirements of the dispenser. Additionally, the power requirements of the pump and relay should be considered to prevent any overload or damage to the components.