Fikret
Published

Touchless Disinfectant Sprayer

Hygene is one of the most important thing at our life. With this project disinfectant liquid is able to spray to hands touchless.

IntermediateFull instructions provided5 hours3,693
Touchless Disinfectant Sprayer

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Arduino Pro Mini 328 - 5V/16MHz
SparkFun Arduino Pro Mini 328 - 5V/16MHz
×1

Software apps and online services

Tinkercad
Autodesk Tinkercad

Hand tools and fabrication machines

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

Story

Read more

Custom parts and enclosures

Tinkercad Files

Schematics

Sprayer Schematics

Code

Arduino Pro Mini Code

Arduino
Usb Serial adapter needed to load firmware (FT232 or equivalent)
#define echoPin A2 // attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin A1 //attach pin D3 Arduino to pin Trig of HC-SR04
int buzzer =3;
int motor =6;
int potPin = A3;

// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
int potVal;
int once = 0;
void setup() {
  pinMode(buzzer,OUTPUT);
  pinMode(motor,OUTPUT);

  pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
  pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
  Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
  Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor
  Serial.println("with Arduino Pro Mini");
  digitalWrite(buzzer,HIGH);
  delay(500);
  digitalWrite(buzzer,LOW);
  delay(500);

}

void loop() {
  // Clears the trigPin condition
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin HIGH (ACTIVE) for 10 microseconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = duration * 0.34 / 2; // Speed of sound wave divided by 2 (go and back)
  // Displays the distance on the Serial Monitor
  
  potVal = analogRead(potPin)/2;
  Serial.print("potVal: ");
  Serial.print(potVal);
  
  
  Serial.print(" once: ");
  Serial.print(once);
  
  Serial.print("  Distance: ");
  Serial.print(distance);
  Serial.println(" mm");
  
  delay(100);
  if (distance <70)
  {
    digitalWrite(buzzer,HIGH);
    //delay(1);
    if (once == 0)
    {
      
       
    digitalWrite(motor, HIGH);
    delay(potVal);
    digitalWrite(motor,LOW);
    
    once =1;
    }
    delay(100);
    digitalWrite(buzzer,LOW);
    
 }
 else
 {
  once=0;
  
  }
 
}

Credits

Fikret
25 projects • 40 followers
fidenetgaraj.blogspot.com

Comments