Projects / Touchless soap and sanitiser dispenser

Touchless soap and sanitiser dispenser

Beginner1.5 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANO8.7 mA

    Test the sensor

    Light the LED when a hand is near.

  2. NANO

    Test the pump

    Run it from the 12 V supply with water.

  3. NANOIRLZ44

    Add the MOSFET

    Switch the pump from the Nano.

  4. NANO

    Set the dose

    Time 0.5 seconds into a measuring spoon.

  5. NANO

    Add the wait

    Block a second dose for 2 seconds.

  6. NANO8.7 mA

    Add the reminder

    Light the LED after your count.

  7. NANO

    Box it

    Keep the electronics dry and fix the tubing.

In short

How do you build a touchless soap and sanitiser dispenser?

An IR sensor triggers a small pump to dispense a measured amount. You need Arduino Nano, IR obstacle avoidance sensor module, Peristaltic pump 12 V, MOSFET IRLZ44N, Rectifier Diode 1N4007, 12 V 2 A DC adapter, LED 5 mm red, Resistor 220 Ω and Resistor 10 kΩ. It takes 7 steps and about 90 minutes.

Level
Beginner
Time
About 90 min
Parts
9

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
IR sensor VCC and GNDNano 5V and GNDPower
IR sensor OUTNano D2Hand detect (LOW when a hand is near)
Nano D5220 Ω resistor to MOSFET gatePump switch
10 kΩ resistorGate to sourceKeeps the pump off at power-up
MOSFET sourceNano GND and 12 V adapter minusCommon ground
MOSFET drainPump minusSwitched return
12 V adapter plusPump plus and Nano VINPower
1N4007Across the pump, stripe to 12 VFlyback protection
Red LED and 220 ΩNano D6 to GNDRefill reminder

Code

The IR module's output goes low when a hand is about 3 to 10 cm in front of it; turn its small screw to set the range. The MOSFET switches the 12 V pump, the diode across the pump absorbs the spike when it stops, and the gate pull-down keeps the pump off while the Nano starts. A peristaltic pump only touches the liquid through its tubing, which makes it good for soap and sanitiser. Use food-safe or medical-grade silicone tubing, keep the electronics in a dry box away from splashes, and wire the supply with a fuse. Sanitiser with a high alcohol content is flammable: keep it away from sparks, hot parts and the electronics, use small quantities, and never put the pump or driver inside the bottle. The refill reminder counts doses rather than measuring the level, so recalibrate it for your bottle. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Touchless dispenser. Board: Arduino Nano. No libraries needed.
const int SENSOR = 2, PUMP = 5, LOW_LED = 6;
const unsigned long DOSE_MS = 500;              // pump time per dose, tune with a measuring spoon
const unsigned long WAIT_MS = 2000;             // pause before the next dose
const int DOSES_PER_REFILL = 200;               // an estimate for your bottle
int doses = 0;
unsigned long lastDose = 0;

void setup() {
  pinMode(SENSOR, INPUT); pinMode(PUMP, OUTPUT); pinMode(LOW_LED, OUTPUT);
  digitalWrite(PUMP, LOW);
}

void loop() {
  if (digitalRead(SENSOR) == LOW && millis() - lastDose > WAIT_MS) {     // hand present, not too soon
    digitalWrite(PUMP, HIGH); delay(DOSE_MS); digitalWrite(PUMP, LOW);
    lastDose = millis(); doses++;
    if (doses >= DOSES_PER_REFILL) digitalWrite(LOW_LED, HIGH);          // time to refill
  }
  delay(20);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Hand in frontOne dose is pumped
Hand held thereNext dose only after the wait
No handPump stays off
After the countRefill LED lights

If it does not work

Pump runs all the time

Check the gate pull-down and the MOSFET pins (gate, drain, source).

Does not trigger

Adjust the sensor range screw and check D2.

Dose too big or small

Change DOSE_MS.

Dripping

Fit a small loop in the tube above the nozzle.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the touchless soap and sanitiser dispenser?

Arduino Nano, IR obstacle avoidance sensor module, Peristaltic pump 12 V, MOSFET IRLZ44N, Rectifier Diode 1N4007, 12 V 2 A DC adapter, LED 5 mm red, Resistor 220 Ω and Resistor 10 kΩ.

How long does the touchless soap and sanitiser dispenser take to build?

About 90 minutes for a beginner maker, in 7 steps.

How do I know the touchless soap and sanitiser dispenser works?

Hand in front: One dose is pumped. Hand held there: Next dose only after the wait. No hand: Pump stays off.

Pump runs all the time: what should I check?

Check the gate pull-down and the MOSFET pins (gate, drain, source).

Does not trigger: what should I check?

Adjust the sensor range screw and check D2.

Dose too big or small: what should I check?

Change DOSE_MS.

Dripping: what should I check?

Fit a small loop in the tube above the nozzle.