Touchless soap and sanitiser dispenser
Build it step by step
0 of 7 doneTest the sensor
Light the LED when a hand is near.
Test the pump
Run it from the 12 V supply with water.
Add the MOSFET
Switch the pump from the Nano.
Set the dose
Time 0.5 seconds into a measuring spoon.
Add the wait
Block a second dose for 2 seconds.
Add the reminder
Light the LED after your count.
Box it
Keep the electronics dry and fix the tubing.
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
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- Motors & ActuatorsBuy
- SemiconductorsBuyMOSFET IRLZ44N × 1
- SemiconductorsBuy
- PowerBuy
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 220 Ω × 1
- PassivesBuyResistor 10 kΩ × 1
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| IR sensor VCC and GND | Nano 5V and GND | Power |
| IR sensor OUT | Nano D2 | Hand detect (LOW when a hand is near) |
| Nano D5 | 220 Ω resistor to MOSFET gate | Pump switch |
| 10 kΩ resistor | Gate to source | Keeps the pump off at power-up |
| MOSFET source | Nano GND and 12 V adapter minus | Common ground |
| MOSFET drain | Pump minus | Switched return |
| 12 V adapter plus | Pump plus and Nano VIN | Power |
| 1N4007 | Across the pump, stripe to 12 V | Flyback protection |
| Red LED and 220 Ω | Nano D6 to GND | Refill 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.
| Check | Expected |
|---|---|
| Hand in front | One dose is pumped |
| Hand held there | Next dose only after the wait |
| No hand | Pump stays off |
| After the count | Refill 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 →
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.
