Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Elegoo Official
Published

Touchless Hand Sanitizer Dispenser

A Touchless Hand Sanitizer Dispenser to avoid transmission of viruses due to hand contact.

BeginnerFull instructions provided1 hour1,507
Touchless Hand Sanitizer Dispenser

Things used in this project

Hardware components

Elegoo Arduino Nano V3+
×1
Servo Motors
×1
Ultrasonic Sensor
×1
Dupont Wires
×1
Breadboard
×1

Story

Read more

Schematics

Touchless Hand Sanitizer Dispenser.jpg

Code

Touchless Hand Sanitizer Dispenser

Arduino
//www.elegoo.com
//2016.12.08
#include "SR04.h"
#include <Servo.h>


#define TRIG_PIN 12
#define ECHO_PIN 11
SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
long a=0;


Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;




void setup() {
  Serial.begin(9600);
  myservo1.attach(2);
  myservo2.attach(3);
  myservo3.attach(4);
  myservo4.attach(5);
  delay(2000);
}


void loop() {
  a=sr04.Distance();
  Serial.print(a);
  Serial.println("cm");
//  delay(300);
if(a<=8&&a>=1)
{
  myservo1.write(120);
  myservo2.write(120);
  myservo3.write(120);
  myservo4.write(120);
  delay(1000);   //
 
 
}
else
{
  myservo1.write(0);
  myservo2.write(0);
  myservo3.write(0);
  myservo4.write(0);
}
 
}

Credits

Elegoo Official

Elegoo Official

3 projects • 18 followers

Comments