Project: Automatic Alcohol Dispenser
Introduction
This is my own version of automatic (No touch / touchless) alcohol / sanitizer dispenser. This is especially useful during this COVID19 pandemic. In here, we will be using an ultrasonic sensor to detect the presence of hand near the dispenser. When the ultrasonic sensor detects an object less than the set distance, it will rotate the attached servo motors to push the plunger of the dispenser.
Bill Of Materials
- Arduino Uno
- HC-SR04 ultrasonic sensor
- MG996R servo motor
- Some wires, dispenser, some piece of wood.
Video Demonstration
Source Code
1#include "Servo.h"
2
3#define ECHO_PIN 6
4#define TRIG_PIN 7
5#define SERVO_PIN 9
6
7Servo myservo; // create servo object to control a servo
8long duration, cm;
9
10void setup() {
11 // put your setup code here, to run once:
12 Serial.begin (9600);
13 pinMode(ECHO_PIN, INPUT);
14 pinMode(TRIG_PIN, OUTPUT);
15 myservo.attach(SERVO_PIN); // attaches the servo on pin 9 to the servo object
16 myservo.write(60);
17 delay(1000);
18 Serial.println("SETUP Complete");
19}
20
21void loop() {
22 // The sensor is triggered by a HIGH pulse of 10 or more microseconds.
23 // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
24 digitalWrite(TRIG_PIN, LOW);
25 delayMicroseconds(5);
26 digitalWrite(TRIG_PIN, HIGH);
27 delayMicroseconds(10);
28 digitalWrite(TRIG_PIN, LOW);
29
30 // Read the signal from the sensor: a HIGH pulse whose
31 // duration is the time (in microseconds) from the sending
32 // of the ping to the reception of its echo off of an object.
33 duration = pulseIn(ECHO_PIN, HIGH);
34
35 // Convert the time into a distance
36 cm = (duration/2) *0.0343; // Speed of sound 0.0343 cm/usec
37 myservo.write(60);
38 if (cm <= 10) {
39 myservo.write(120); // sets the servo position
40 }
41 delay(400);
42}
Call To Action
If you have any question, please do not hesitate to leave it in the comment box. Please Subscribe to my Youtube channel so that you will not missed interesting tutorials like this. Thank you and have a good day. Happy tinkering.
Posts in this series
- How to Get Started with ATTiny85 in Arduino IDE
- Tutorial: How to use MFRC522 RFID module using Arduino
- SOS Flasher Using Millis Function with Enable Switch
- Tutorial: How to use DS3231 RTC in Arduino
- Tutorial: How to use 0.96 OLED - a small and cute display
- Tutorial: Getting Started with the NRF24L01 | How to use | Arduino
- Tutorial: How to use SIM800L GSM Module for Controlling Anything | Arduino
- Tutorial: How to use Keypad | Text Entry Mode | Arduino
- Tutorial: How to use 4x4 Keypad | Arduino
- Project Idea: Arduino Voltmeter
- Project Idea: Door Lock Security | Arduino
- Multitasking with Arduino | Relay Timer Controller | using millis
- Tutorial Understanding Blink Without Delay | How to millis
- Arduino Simple LCD Menu
- How to use SIM800L GSM Module using Arduino | Make or Answer Voice Calls
- Tutorial: How to Use Arduino Uno as HID | Part 2: Arduino Mouse Emulation
- Tutorial: How to Use Arduino Uno as HID | Part 1: Arduino Keyboard Emulation
- Tutorial: How to use SIM800L DTMF to Control Anything | Arduino
- Tutorial: Arduino EEPROM
- How to use SIM800L GSM Module | Arduino | Send and Receive SMS
- 16x2 LCD Menu for Arduino
- Tutorial: Arduino GPIO | How to use Arduino Pins
- MIT App Inventor for Arduino
- RC Car using L298N, HC-06, and Arduino Uno
- How to Use LCD Keypad Shield for Arduino
- How to Use Arduino Interrupts
- TUTORIAL: How to use HC-SR04 Ultrasonic Sensor with Arduino
- Source Code: Astronomia Meme and Funeral Dance | melodies the Arduino way
- How to Get Started with L293D Motor Driver Shield with Arduino
- How to Get Started with L298N Motor Driver module using Arduino
- Part 2: Wav Music Player with Lyrics Using Arduino and SD Card
- Interfacing Infrared to Arduino Uno
- Part 1: Wav Music Player Using Arduino Uno and SD Card
- How to Interface Stepper Motor to Arduino Uno
- How To Play MP3 Files on Arduino from SD Card
- What is Arduino Software Serial
- How to Interface SD card to Arduino (without SD card shield)?
- Playing Melodies Using Arduino
- 8 Degrees Of Freedom (DOF) Robot Using Arduino Uno
- How to Interface PS2 Controller to Arduino Uno
- Part 3: DF Player Mini Tinkering with Arduino Nano and LCD
- How to Interface HC-06 to Arduino
- How to make a Remote Control RC car using Arduino and HC-06 bluetooth module
- Part 2: DF Player Mini Tinkering with Arduino Nano
- Part 1: DF Player Mini - a mini cheap mp3 player
No comments yet!