Introduction: Automatic Soap Dispenser for Washing Machines

Picture of Automatic Soap Dispenser for Washing Machines

This is an automatic soap dispenser that uses peristaltic pumps to move both detergent and softener. It has 6 buttons, 3 are for soap, and 3 are for softener. of the 3 buttons, one dispenses just a little bit of soap/softener, one dispenses a medium amount, and one dispenses yet more. How much each button dispenses is configurable in the software that runs on the Arduino.

Step 1: Gather Parts

Parts needed:

  • 2 Peristaltic pumps
  • 6 buttons
  • 1 enclosure (I 3D printed mine)
  • 2 N-Channel MOSFETs
  • 1 Arduino (any will do, I used a Nano)
  • 1 12V 1A power supply
  • Some tubing that is roughly the same size as the pump's tubing
  • 4 Hose barbs to join the pumps to the above tubing
  • 1 Power supply connector
  • Misc wires to join it all together

See the last step for exactly which parts I used.

Step 2: Build the Prototype

Picture of Build the Prototype
  • To do this, you will first want to program the arduino. Copy and paste the below code into the Arduino Sketch editor and upload it.
  • Create the wiring diagram above with the arduino, MOSFETs, and pumps. The capacitor isn't completely necessary, but will help the motors start if your power supply is less than 1A.
  • Refer to the #define statements in the code below for the Arduino pinout. "Arduino +" in the diagram should be hooked up to "VIN" on the Arduino.
  • Wire the buttons up as well. They are not included in the wiring diagram. They should have one lead connected to ground and the other lead connected to the corresponding Arduino pin.
<p>// timings. middle button computes the average between max and min.<br>// pumps start when the button is first pushed.
// time starts when the button is released.
#define SOAP_MIN_DURATION 1000
#define SOAP_MAX_DURATION 3000
#define SOFT_MIN_DURATION 1000
#define SOFT_MAX_DURATION 3000</p><p>// button pins. 1 is shortest duration.
#define SOAP_1 2
#define SOAP_2 3
#define SOAP_3 4
#define SOFT_1 5
#define SOFT_2 6
#define SOFT_3 7
#define MOTOR_SOAP 8
#define MOTOR_SOFT 9</p><p>void setup() {
  pinMode(SOAP_1, INPUT_PULLUP);
  pinMode(SOAP_2, INPUT_PULLUP);
  pinMode(SOAP_3, INPUT_PULLUP);
  pinMode(SOFT_1, INPUT_PULLUP);
  pinMode(SOFT_2, INPUT_PULLUP);
  pinMode(SOFT_3, INPUT_PULLUP);
  pinMode(MOTOR_SOAP, OUTPUT);
  pinMode(MOTOR_SOFT, OUTPUT);
}</p><p>uint32_t current_time;
uint32_t next_time;
uint32_t soap_off_time = 0;
uint32_t soft_off_time = 0;</p><p>void loop() {
  next_time = millis();
  if (next_time < current_time) {
    // time has rolled over. congratulations on leaving this plugged in for 49.7 days.
    soap_off_time = 0;
    soft_off_time = 0;
  }
  current_time = next_time;</p><p>  // check if the soap pump should be running
  if (soap_off_time > current_time) {
    digitalWrite(MOTOR_SOAP, HIGH);
  } else {
    digitalWrite(MOTOR_SOAP, LOW);
  }</p><p>  // check if the softener pump should be running
  if (soft_off_time > current_time) {
    digitalWrite(MOTOR_SOFT, HIGH);
  } else {
    digitalWrite(MOTOR_SOFT, LOW);
  }</p><p>  // check if we need to do anything for any of the buttons
  if (!digitalRead(SOAP_1)) {
    soap_off_time = current_time + SOAP_MIN_DURATION;
  }
  if (!digitalRead(SOAP_2)) {
    soap_off_time = current_time + (SOAP_MIN_DURATION + SOAP_MAX_DURATION) / 2;
  }
  if (!digitalRead(SOAP_3)) {
    soap_off_time = current_time + SOAP_MAX_DURATION;
  }
  if (!digitalRead(SOFT_1)) {
    soft_off_time = current_time + SOFT_MIN_DURATION;
  }
  if (!digitalRead(SOFT_2)) {
    soft_off_time = current_time + (SOFT_MIN_DURATION + SOFT_MAX_DURATION) / 2;
  }
  if (!digitalRead(SOFT_3)) {
    soft_off_time = current_time + SOFT_MAX_DURATION;
  }
}
</p>

Step 3: Assembly

Picture of Assembly

Now it's time to assemble it all and put it in the enclosure. I chose to put the power circuitry on a PCB. This is not required, it just makes it come out a little cleaner.

The buttons can be wired with only one ground wire as pictured.

After wiring the buttons and getting the power circuitry completed, I suggest putting hot glue on the wires as strain relief. This is not required either, but will make this last a lot longer. If this will be used in a warm environment, I would recommend some other type of glue.

Step 4: Test the Assembly

Picture of Test the Assembly

Now it's time for final testing! set it up somewhere with a couple cups of water, plug it in, and see if it works.

To purge air out of the system, you can just hold a button and the pump will continue to run.

Step 5: Install on Washing Machine and Tune Timings

To install this on a washing machine, plan out where the control box will sit, where your detergent and softener bottles will be, and where the pumps will be. I recommend having the pumps as close to the opening of the bottles as possible, even sitting on top. This makes purging air out of the system significantly easier.

Lengthen pump wires as needed, cut tubing, and put it all together.

You will also need to tune the pump timings to get the correct amount of detergent/softener. This is easily done in the code in the indicated places.

Step 6: Notes on Parts

Here is a list of exactly which parts I used, and some alternatives that may work. I sourced most of my parts from Ebay. Just use the search for something similar.

  • pumps
    ZJchao 12v Dc Diy Dosing Pump Peristaltic Dosing Head
  • power supply (I recommend upgrading to 1A or more)
    Power Adapter Supply 12V 500mA 0.5A DC 100-240V 5.5/2.5mm 5.5/2.1mm Standard
  • hose barbs
    (5 Pieces) 1/8" Hose Barb Mendor Union Splicer Brass Fitting Gas Fuel Water Air
  • buttons
    Red 50Pcs Mini Momentary On/Off Lockless Micro Push Button SPST Switch
  • arduino
    MINI USB Nano V3.0 ATmega328P CH340G 5V 16M Micro-controller board For Arduino N
  • tubing. get more if your pumps are at all far from your washing machine.
    TBL Low-Density Polyethylene Tubing LDPE .170" ID x .25" OD x 7ft OAL
  • My enclosure was 3D printed but pretty much any hobby enclosure should work. I can upload my model if anyone is interested.
  • N-channel Mosfets. I used some I had laying around. Any logic level MOSFETs that support more than 5A should work. Need 1 for each motor. Something like these would work great if you don't have any laying around.
    5Pcs IRLZ44N PBF Power MOSFET Logic Level N-Channel 0.022OHM TO-220 IC Chip
  • power supply connector
    10pcs DC Power Female Jack Barrel Plug Connector 2.1 x 5.5 mm Adapter Terminal

Comments

mooster (author)2017-10-03

It looks awesome, but I'm too lazy to make it. Would you come over and make one for us please? I'd definitely pay for this. I hate to mess around with the drippy detergent bottle and measuring lid. The laundry machine manufacturers will be stealing your idea soon, I predict.

DIY Hacks and How Tos (author)2017-10-01

Cool system. One step closer to fully automated laundry.

About This Instructable

613views

14favorites

License:

More by mrclark25:Automatic Soap Dispenser for Washing Machines
Add instructable to: