Nikolaos Babetas
Published © CC BY-NC-SA

Automatic Hand Sanitizer

This accessory can be attached to most hand sanitizer/soap dispensers to make them Completely Automatic and Hands-Free!

IntermediateFull instructions provided20 hours53,389
Automatic Hand Sanitizer

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Driver DRV8825 for Stepper Motors for Theremino System
Driver DRV8825 for Stepper Motors for Theremino System
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
I used 2 mini breadboards but anything will work fine
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Capacitor 100 µF
Capacitor 100 µF
×1
28BYJ-48 4 Phase Stepper Motor DC 5V For Arduino (OEM)
×1
M3 Screw any lenght from 8mm to 20mm
×19
Infrared Obstacle Avoidance Sensor Module for Arduino
×1
Limit Switch KW12-3 - Micro Roller Lever Arm Normally Open/Close
×1
Aluminium Rigid Coupling 5mm to 8mm
×1
Trapezoidal Lead Screw T8-300mm with Brass Nut, Pitch 2mm
×1
On-Off switch (generic)
×1
Hand Sanitizer
×1
688zz Ball Bearing 8x16x5mm
×1
LM8UU 8x15x24mm Solid Polymer Linear Bearing
×1
Velcro ties
×1

Software apps and online services

Arduino IDE
Arduino IDE
3D design program
(optional) I used Onshape
Ultimaker Cura
(Slicer for 3D printing)

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Mine is the Creality3D Ender 3 V 2
Soldering iron (generic)
Soldering iron (generic)
(optional)
Hacksaw (generic)

Story

Read more

Custom parts and enclosures

Base

The main base of the device.

Presser

This is the component that actually presses the dispenser.

Cover

The cover of the device.

Electronics Case

Acts as a case for the electronics.

Velcro grip

Creates the Velcro tying mechanism.
You will need two of these.

8mm rod

Acts as support for the presser part.

IR Obstacle sensor holder

It gets connected to the base and acts as support for the ir sensor.

Velcro holder

Holds the Velcros on the cover.
You will need 2 of these.

Schematics

Cirscuit Diagram

Code

Automatic_Hand_Sanitizer_Transformer.code

Arduino
The code of the gadget
// Define pin connections & motor's steps per revolution
const int dirPin = 2; //we define the dir pin of the driver
const int stepPin = 3;//we define the step pin of the driver
const int enablePin = 4;//we define the enable pin of the driver
const int stepsPerRevolution = 6000; // one full (360 degree) rotation is 2048 steps
int endStop = 8;//we define the input pin of the endstop switch
int irSensor = 9;//we define the input pin of the IR obstacle sensor




void setup()
{
  
  pinMode(endStop, INPUT);// Declare pins as Inputs
  pinMode(irSensor,INPUT);
   
  pinMode(stepPin, OUTPUT);// Declare pins as Outputs
  pinMode(dirPin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  
  digitalWrite(enablePin, LOW);// This enables our driver
  
  while(digitalRead(endStop) == LOW)// When the code starts the stepper will rotate until the end stop switch 
  {                                 //stop switch gets activated
    
   digitalWrite(dirPin, HIGH); //the directions is set as anti-clockwise

  // Spin motor slowly
  for(int x = 0; x < 1; x++)
  {
  
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);
  }
    
  }
digitalWrite(enablePin, HIGH);// This disables our driver so that when not 
                              //in use the driver does not consume current
}

void loop()
{
  
     if(digitalRead(irSensor)== 0)// If there is an obstacle (hand) in front of the IR Obstacle sensor
     {
digitalWrite(enablePin, LOW);//We enable the driver
digitalWrite(dirPin, LOW);// the direction is set as clockwise

  // Spin motor slowly
  for(int x = 0; x < stepsPerRevolution; x++)// it rotates for the number of steps we declared above(remember one full rotation is 2048 steps)
  {
  
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);
  }
  delay(2000); // It waits for 2 seconds
  
  while(digitalRead(endStop) == LOW) //Rotates clockwise until the endstop switch 
  {                                  //is activated thus returning to starting position
    
   digitalWrite(dirPin, HIGH);//the directions is set as anti-clockwise

  // Spin motor slowly
  for(int x = 0; x < 1; x++)
  {
  
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);
  }
    
  }
  digitalWrite(enablePin, HIGH);// the driver gets disabled 
      
     }
 
}

Credits

Nikolaos Babetas

Nikolaos Babetas

4 projects • 15 followers
My name is Nikolas and I am 15 years old. I love making things with electronics and 3D printing to satisfy my imagination and curiosity!

Comments