Do you hate doing the dishes? Do you wish there was a way to make this chore less tedious and more fun? Do you have a spare Raspberry Pi Pico lying around and some basic electronics skills? If you answered yes to any of these questions, then this project is for you!
In this post, I will show you how to make a washing up liquid dispenser that automatically squirts soap onto your sponge when you bring it close. No more picking up the bottle and squeezing it every time you need more soap. Just wave your sponge in front of the sensor and watch the magic happen!
What You Will Need
To make this project, you will need the following parts:
- A Raspberry Pi Pico: This is the brain of the dispenser. It will control the pump and read the distance sensor. You can use any other microcontroller that supports Python, but I chose the Pico because it's cheap and powerful.
- A 12V DC peristaltic pump: This is the heart of the dispenser. It will pump the washing up liquid from a reservoir to your sponge. You can find these pumps online or in some hardware stores. They are often used for aquariums or medical applications.
- An ultrasonic distance sensor (HC-SR04): This is the eye of the dispenser. It will measure how far your sponge is from the sensor and trigger the pump accordingly. You can also use an infrared sensor or a capacitive touch sensor if you prefer.
- A motor driver module (DC Dual H-Bridge HW-095): This is the muscle of the dispenser. It will drive the pump with 12V power and also provide 5V power to the Pico. You can use any other motor driver that can handle 12V and has two channels, but I like this one because it's compact and easy to use.
- A 12V power supply: This is what keeps everything running. You can use any 12V adapter that can deliver enough current for your pump. Mine draws about 300mA at full speed.
- Some wires, connectors, screws, etc.: These are what hold everything together. You will need some jumper wires to connect everything on a breadboard or a protoboard, some spade connectors to connect the pump to the motor driver, some screws to mount everything on a case or a jar lid, etc.
How It Works
The logic behind this project is very simple:
1) The Pico reads the distance from the sensor using its GPIO pins.
2) If the distance is within a certain range (e.g., between 5cm and 15cm), it sends a signal to one channel of
the motor driver using another GPIO pin.
3) The motor driver turns on one channel and supplies 12V power to
the pump for a set amount of time (e.g., 0.5 seconds).
4) The pump pushes some washing up liquid from
the reservoir through a tube to your sponge.
5) The Pico turns off
the signal and waits for another trigger.
That's it! You can adjust
the parameters according to your preferences and needs.
Code
from machine import Pin
import utime
from machine import Pin, Timer
trigger = Pin(3, Pin.OUT)
echo = Pin(2, Pin.IN)
motor = Pin(22, Pin.OUT)
timer = Timer()
def ultra():
trigger.low()
utime.sleep_us(2)
trigger.high()
utime.sleep_us(4)
trigger.low()
while echo.value() == 0:
signaloff = utime.ticks_us()
while echo.value() == 1:
signalon = utime.ticks_us()
timepassed = signalon - signaloff
distance = (timepassed * 0.0343) / 2
if 10 < int(distance) < 15:
motor.toggle()
utime.sleep(0.5)
motor.toggle()
while True:
ultra()
if you enjoyed this blog post please consider supporting me on patreon:
Comments