Automatic Mask and Sanitizer dispenser Using Arduino

Hello friends, welcome to yet another Interesting Arduino project from TexoBot.

This time, we will learn how to create an Automatic Face Mask and Sanitizer dispenser with the help of Arduino microcontroller.

This project has been specially created for our YouTube channel subscribers. As a Tech channel, we believe that it is our sole responsibility to contribute our Tech ideas towards fighting against the current pandemic(covid-19). Thus we created a fully automatic vending machine system which will help us to avoid any sort of virus contacts while using the Covid-19 protective measures like Face mask and hand sanitizers.

There are a lot of sanitizer projects available around, but none of those ideas were having an all in one combo package(Sanitizer + Face mask in one unit).

Please watch the video to know more about the project.

Please find the connection diagram below.

Components / Buying Links

  1. Arduino UNO ........ /

  2. L298N Motor Driver ......... /

  3. Infrared Module......... /

  4. DC Geared Motor 12V (1000 RPM) .........

  5. DC submersible Pump......... /

  6. Male and Female Jacks for Arduino ......... /

  7. 12V 2AMP DC Adapter......... /

  8. 10uF 25V capacitor .............. /

Other materials

  1. PVC Ceiling panel - Purchase from local Market(It may be available in Aluminum fabrication shops)

  2. Aluminum Angle bar - Purchase from local Market(It may be available in Aluminum fabrication shops)

Required Tools

  1. Hand riveter gun .......... /

  2. Drilling machine ........... /

  3. Flex quick(Super Glue) ......... /

  4. Soldering Iron ........ /

Arduino Code:

int IRSensorS = 12; // connect ir sensor for sani to arduino 12

int IRSensorM = 8; // connect ir sensor for mask to arduino pin 8

int fla = A2; // Motor Driver 2 Pins IN1

int flb = A3; // Motor Driver 2 Pins IN2

int san = 5; // Motor Driver 2 Pins IN3

int san1 = 6; // Motor Driver 2 Pins IN4

int pwm = 9;

void setup() {


pinMode(pwm, OUTPUT);

pinMode(IRSensorM, INPUT);

pinMode(fla, OUTPUT); // Digital pin A2 set as output Pin

pinMode(flb, OUTPUT); // Digital pin A3 set as output Pin

pinMode(IRSensorS, INPUT);

pinMode(san, OUTPUT); // Digital pin 10 set as output Pin

pinMode(san1, OUTPUT); // Digital pin 10 set as output Pin


void loop() {



while(digitalRead ((IRSensorS) == HIGH)&&(IRSensorM) == HIGH);

if (digitalRead (IRSensorS) == LOW) {


digitalWrite( san1, HIGH);


digitalWrite( san1, LOW);

while(digitalRead (IRSensorS) == LOW);

}else if(digitalRead (IRSensorS) == HIGH){

digitalWrite( san1, LOW);


if (digitalRead (IRSensorM) == LOW) {


analogWrite(pwm, 140);


digitalWrite( fla, HIGH);

digitalWrite( flb, LOW);


digitalWrite( fla, LOW);

digitalWrite( flb, LOW);

analogWrite(pwm, 255);

while(digitalRead (IRSensorM) == LOW);


}else if(digitalRead (IRSensorM) == HIGH){

digitalWrite( fla, LOW);

digitalWrite( flb, LOW);