Automatic Soap Dispenser Using Maker UNO

INTRODUCTION

The number of people who have tested positive for Covid-19 is increasing??. One of the ways to protect us from the coronavirus is to wash our hands? regularly using soap?. So, please wash your hand frequently with soap and stay at home.

HARDWARE PREPARATION

This tutorial use :

Software Preparation.

Sample Code

This is the sample code used for this tutorial. Try it!

#include <Servo.h>
Servo myservo1; // create servo object to control a servo1
Servo myservo2; // create servo object to control a servo2
const int sensorPin = 3; // the number of the IR sensor pin
int sensorState = 0; // variable for reading the IR sensor status
void setup() {
// initialize the IR sensor pin as an input:
pinMode(sensorPin, INPUT);
myservo1.attach(5);
myservo2.attach(6);
}
void loop() {
// read the state of the IR sensor value:
sensorState = digitalRead(sensorPin);
// check if the sensor detects any object. If it is, the sensorState is HIGH:
if (sensorState == HIGH) {
myservo1.write(180); // sets the servo position to 180 degree
myservo2.write(0); // sets the servo position to 0 degree
delay(15);
} else {
myservo1.write(0); // sets the servo position to 0 degree
myservo2.write(180); // sets the servo position to 180 degree
delay(15);
}
}
view raw soap_dispenser.ino hosted with ❤ by GitHub

Thank you

Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiry, please post at Cytron Technical Forum.

2 thoughts on “Automatic Soap Dispenser Using Maker UNO”

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Object Sense With Servo Using Maker Pi RP2040
Build Otto DIY Robot Using Maker Pi RP2040
Raspberry Pi RP2040 vs STM32F1 vs SAMD21G18 vs ESP32-S2
The Easiest Way to Print Temperature Tower Using Cura 4.9.1 Plugins
IoT on Raspberry Pi Pico using CircuitPython and Adafruit IO
Tutorials of Cytron Technologies Scroll to Top