Arnov Sharma
Published © GPL3+

Arduino Soap/Sanitizer Dispenser (overkill version)

Basically an overkill soap dispenser made from CNC linear rail

BeginnerFull instructions provided8 hours4,167

Things used in this project

Hardware components

Stepper motor driver board A4988
SparkFun Stepper motor driver board A4988
×1
nema 17 stepper motor
×1
12V lithium ion battery pack
×1
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
everything above can be found here for a low price
×1
Arduino UNO
Arduino UNO
×1
JLCPCB Customized PCB
JLCPCB Customized PCB
×1

Software apps and online services

Fusion 360
Autodesk Fusion 360
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

3D files

Schematics

sch

Code

code

C/C++
int trigPin = 11; 
int echoPin = 10; 

const int stepPin = 13; 
const int dirPin = 12; 

void setup()
{  
pinMode(trigPin, OUTPUT); //Sensor
pinMode(echoPin, INPUT); //Sensor  
pinMode(stepPin,OUTPUT); // Step
pinMode(dirPin,OUTPUT); // Dir
Serial.begin(9600);
} 

void loop(){
  

long duration, distance;
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(5);
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = (duration/2) / 29.1;
 Serial.print ("cm ");
 Serial.print (distance);



if (distance < 30)
{
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
  // Makes 300 pulses for making one full cycle rotation
  for(int x = 0; x < 250; x++) {
    digitalWrite(stepPin,HIGH); 
    delayMicroseconds(600); 
    digitalWrite(stepPin,LOW); 
    delayMicroseconds(600); 
  }
delay(1000); // One second delay
  
  digitalWrite(dirPin,LOW); //Changes the rotations direction
  // Makes 300 pulses for making two full cycle rotation
  for(int x = 0; x < 250; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(600);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(600);
  }
}
}

Credits

Arnov Sharma

Arnov Sharma

265 projects • 272 followers
Just your average MAKER

Comments