Arnov Sharma
Published © CC BY-NC-SA

Yet Another Solenoid Valve Based SANITIZER DISPENSER

3D Printed and easy to Replicate "Fluid Dispenser for alcohol-based sanitizer".

BeginnerFull instructions provided10 hours3,437

Things used in this project

Story

Read more

Custom parts and enclosures

container lid

container

lid of lid

wall mount bracket

Schematics

SCH for PCB

Code

code for ultrasonic sensor

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

int SOL = 13; //solenoid

void setup()
{  
pinMode(trigPin, OUTPUT); //Sensor
pinMode(echoPin, INPUT); //Sensor  
pinMode(SOL, OUTPUT);
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 < 10)
{
  digitalWrite(SOL,HIGH);
}
else
  {
    //Serial.println("CLEAR");
    digitalWrite(SOL,LOW);

      }

  delay(200);
}

code for Proximity sensor

C/C++
int SOL = 0; 
int SENSOR = 1;

int isObstacle = 0;  

void setup() {
  pinMode(SOL, OUTPUT);
  pinMode(SENSOR, INPUT);

  //Serial.begin(9600);
  
}

void loop() {
  isObstacle = digitalRead(SENSOR);
  if (isObstacle == LOW)
  {
    //Serial.println("SOMETHING IS PASSING");
    digitalWrite(SOL,HIGH);

  }
  else
  {
    //Serial.println("CLEAR");
    digitalWrite(SOL,LOW);

      }

  delay(200);
  

}

Credits

Arnov Sharma

Arnov Sharma

308 projects • 306 followers
Just your average MAKER

Comments