studentmaker3925
Published © CC BY-NC-SA

Sanitizer Auto Pumping Machine

Turn all pumping containers into non-contact as well as hand sanitizers using only Arduino and servo motors

BeginnerProtip5,644
Sanitizer Auto Pumping Machine

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
MG996 servo motor
×1
Capacitor 1000 µF
Capacitor 1000 µF
×1
Male/Male Jumper Wires
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Laser cutter (generic)
Laser cutter (generic)
It's not mandatory. Just what you need to make a nice case

Story

Read more

Custom parts and enclosures

STL FILE

STL FILE

STL FILE

STL FILE

Schematics

Circuit

Code

Code

C/C++
/*
echo = 3
trig = 4
servo = 5
*/

#include  <Servo.h>
Servo myservo;

int first_angle = 100; //you can change the value.
int second_angle = 50; //you can change the value.
int detection_distance = 20; //(cm)you can change the value.

int sw = 12; //Switch
int echoPin = 3; //ultrasonic sensor echoPIN
int trigPin = 4; //ultrasonic sensor trigPIN

void setup() {
  myservo.attach(5);
  myservo.write(first_angle);
  pinMode(sw, INPUT_PULLUP);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop(){
  digitalWrite(trigPin, LOW);
  digitalWrite(echoPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  unsigned long duration = pulseIn(echoPin, HIGH);
  float distance = duration / 29.0 / 2.0;

  if (digitalRead(sw) == LOW){
   if (distance <= detection_distance){
      myservo.write(second_angle);
      delay(400);
      myservo.write(first_angle);
      delay(800);
    }
  }
  else{
    myservo.write(first_angle);
  }
}

Credits

studentmaker3925

studentmaker3925

0 projects • 0 followers

Comments