How to make a simple automatic control DIY hand sanitizer bottle using Arduino
Hello, welcome back. In this tutorial, we will learn how to make a simple automatic control DIY hand sanitizer bottle using Arduino. This project is mainly based on an IR infrared sensor and the Arduino UNO board. Also, this is designed using a spray bottle so you can continue to use it. This tutorial will cover how to create this very simple and this project will be a great help in protecting against the COVID-19 virus. Keep reading.
The process of this project
When connecting to the power source, the IR sensor begins to emit IR rays. Then, when our hand is close to the sensor, a signal is sent through it to the Arduino board. At this point, the servo motor rotates left and right. Then, the lever on the spray bottle moves back and forth. As a result, the liquid in the spray bottle is sprayed.
OK, let’s do this project. The required components are given below.
- Arduino UNO board x 1 — Our Store / Amazon
- IR ifrared sensor x 1 — Our Store / Amazon
- Spray bottle x 1 — Amazon
- Servo motor x 1 — Our Store / Amazon
- Jumper wires — Our Store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.
Step 2
Secondly, attach the IR infrared sensor to the top of the spray bottle.
Step 3
Thirdly, connect the servo motor as follows.
Step 4
Afterwards, dig a hole in the lever and connect it to the servo motor using a thread.
Step 5
Then, connect these components to the Arduino board. For that, use the circuit diagram below. Also, you must remember to connect an external power supply to the servo motor.
Step 6
Now, connect the Arduino board to the computer and upload the program. It is as follows. The degree values of this servo motor depend on your project. So do not enter the following values.
- The complete program of this project – Download
/*Auto control sanitiser bottle with Arduino
* https://srituhobby.com
*/
#include <Servo.h>
#define Servopin 3
#define Sensorpin 2
Servo srituhobby;
void setup() {
Serial.begin(9600);
srituhobby.attach(Servopin);
pinMode(Sensorpin, INPUT);
srituhobby.write(160);
}
void loop() {
bool value = digitalRead(Sensorpin);
Serial.println(value);
if (value == 0) {
srituhobby.write(90);
delay(5);
srituhobby.write(160);
delay(5);
} else {
srituhobby.write(160);
}
}
Code explanation
Firstly, the servo motor library is included. After that, the servo motor PIN and the sensor PIN are defined.
#include <Servo.h>
#define Servopin 3
#define Sensorpin 2
Secondly, the object is created for this library.
Servo srituhobby;
In the setup function,
void setup() {
//The serial monitor is begin
Serial.begin(9600);
//Includes the servo motor pin
srituhobby.attach(Servopin);
//The sensor pin is set as an input pin
pinMode(Sensorpin, INPUT);
//Sets the servo motor start point
srituhobby.write(160);
}
In the loop function,
void loop() {
//Gets the sensor values
bool value = digitalRead(Sensorpin);
Serial.println(value);
//These values are checked using the IF condition. If the sensor value is 0, the servo motor rotates from 60 degrees to a 160 degrees
//Also, these degree values depend on the position of your servo motor horn
if (value == 0) {
srituhobby.write(90);
delay(5);
srituhobby.write(160);
delay(5);
} else {
srituhobby.write(160);
}
}
Step 7
Now, select board and port. After, upload this code to the Arduino board.
Step 8
Then, unplug the USB cable and connect an external 5V power supply to the Arduino board. For that, use the circuit diagram above.
Step 9
Finally, add the liquid to the spray bottle and enjoy this project. The full video guide is given below. So, we will meet in the next tutorial.
How to make a simple automatic control DIY hand sanitizer bottle using Arduino
This is interestingly good ..
Thank you