Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

How to design a touchless bell

push using Arduino


January 8, 2021 By Nikhil Agnihotri

The COVID-19 pandemic has severely affected the lives of millions


across the world. It has caused a significant increase in the
awareness of health and better hygiene. As a result, the electronics
industry has experienced a rapid demand for touchless devices and
appliances, such as contactless sanitizer or soap dispensers and
automatic doors.

For this project, we’ll design a touchless bell push, which can be
useful in homes or offices. The bell uses an ultrasonic sensor that
can be easily assembled with little cost.

We’ve prototyped the touchless bell push using Arduino, which


means the code can be ported to any Arduino-compatible platform.

Required components

1. Arduino UNO x1
2. HC-SR04 ultrasonic sensor x1
3. Buzzer x1
4. Breadboard
5. Connecting wires/jumper wires

Circuit connections
To assemble the touchless bell push, an HC-SR04 ultrasonic sensor
and a buzzer are interfaced with an Arduino board. Arduino UNO is
used for this project.

The HC-SR04 ultrasonic sensor has four terminals: VCC, trigger,


:
echo, and ground. The sensor’s VCC and ground terminals are
connected with a 5V DC supply and ground from Arduino. The
sensor’s trigger and echo terminals are connected with Arduino’s
pins 8 and 9, respectively. The buzzer is connected to Arduino’s pin
7.

Circuit diagram

Arduino sketch

#include <NewPing.h>

#define TRIGGER_PIN 8
#define ECHO_PIN 9
#define MAX_DISTANCE 400
const int buzzer = 7;
:
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
float distance;
int i;

void setup()
{
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer,HIGH);
}

void loop()
{
distance = sonar.ping_cm();
if (distance < 10)
{
for(i=0;i<20;i++)
{
digitalWrite(buzzer,HIGH);
delay(50);
digitalWrite(buzzer,LOW);
delay(50);
}

for(i=0;i<20;i++)
{
digitalWrite(buzzer,HIGH);
delay(55);

digitalWrite(buzzer,LOW);
delay(55);
}
:
for(i=0;i<2;i++)
{
digitalWrite(buzzer,HIGH);
delay(60);
digitalWrite(buzzer,LOW);
delay(60);
}

for(i=0;i<2;i++)
{
digitalWrite(buzzer,HIGH);
delay(65);
digitalWrite(buzzer,LOW);
delay(65);
}

for(i=0;i<2;i++)
{
digitalWrite(buzzer,HIGH);
delay(70);
digitalWrite(buzzer,LOW);
delay(70);
}

}
digitalWrite(buzzer,HIGH);
}

How the circuit works


The touchless bell push lets a user ring the bell without touching it.
:
The HC-SR04 ultrasonic sensor is interfaced with Arduino to allow
for contactless operation.

The sensor can detect an obstacle or object that’s up to 400 cm


away. It consists of two ultrasonic transducers: one that transmits 40
kHz ultrasonic sound pulses and another that “listens” for the pulses
that vibrate off of the obstacle or object. By measuring the width of
these received pulses, the sensor assesses the distance from the
object.

The HC-SR04 is capable of non-contact detection at a distance


ranging between 2 and 400 cm with an accuracy of 3 mm. The
sensor requires 5Vs of operating voltage, which is compatible with
most microcontrollers and Arduino boards.

For this project, the HC-SR-04 is only used for non-contact


detection up to 10 cm. This distance is adequate for use of the
contactless bell as a doorbell or desk bell.

A piezo buzzer is interfaced with Arduino and it works as the bell. It’s
wired to ring when a LOW logical signal is output from Arduino’s
interfaced pin. It stays silent when a HIGH logic is applied from the
Arduino pin to the buzzer terminal.

Arduino is programmed to ring the buzzer when the ultrasonic


sensor detects interference at a distance of less than 10 cm. The
buzzer sounds because of the application of a combination of
square-wave frequencies at short intervals. These square waves are
generated by Arduino’s GPIO digital output.

How the code works


Begin the Arduino sketch by importing the NewPing library. This
library is useful for interfacing the HC-SR04 ultrasonic sensor with
Arduino. The library can be downloaded as a ZIP file from the above
:
link.

To install the library, simply open the Arduino IDE, go to Sketch >
Include Library > Add .ZIP Library, and then select the NewPing ZIP
file that you just downloaded.

Follow this step with the pin assignments, interfacing the sensor’s
trigger and echo terminals with the buzzer.

Then, an object “sonar” (from the NewPing class) must be


instantiated. And, a variable “distance” must be declared to store the
distance of the non-contact detection and a variable “I,” which runs
the counters.

In the setup() function, the buzzer pin is set to output and raised to
HIGH logic by using the digitalWrite() function. In the loop() function,
the distance to any interference is detected using the NewPing
class’s ping_cm() method.

If the distance of the non-contact detection is less than 10 cm, the


buzzer is rung by generating different square-wave frequencies.
These square waves are generated by writing alternative LOW and
HIGH logic to the buzzer pin — with different time delays. Finally, the
buzzer is set to silent by applying a HIGH logic to the buzzer pin.

Results
:
:
Filed Under: Arduino, Microcontroller Projects
Tagged With: Arduino
:
:
:
:
:
:

You might also like