Social Distancing Alarm

Build & Code a smart Device using an Ultrasonic sensor, LED and Buzzer to check whether distance between two persons is Safe or Unsafe.

 

What is a Social Distancing Alarm?

Due to Covid19 Pandemic, we all are advised to maintain a particular distance from everyone around us, but sometimes we do not know how far we are from a person around us. Social Distancing Alarm will start ringing with RED led “ON” whenever any person around us is not maintaining social distance and will Green Led “ON” whenever all the people around us are maintaining social distance.

This activity will be performed with the help of a distance measurement sensor where it will set a certain distance limit and then check whether it is correct or not.

The distance that we will be checking will be centimeters.

What do we need?

For implementing this project we will need –

1.   Ultrasonic Sensor
2.   Controlled Board (Arduino Nano)
    3 .LED(Red and Green)
    4. Resistors x2 (330 ohm)
    5. Buzzer

 

Connections –

The Ultrasonic sensor shall be connected to 4 pins of the controller board. Plug the wires from the Ultrasonic sensor to the Controlled board slot marked as “Ultrasonic”. These connect on Vcc pin, Gnd pin, Analog pins A0, and A1.

Connect Green Led’s Anode with Pin 13 and Cathode in series with 330 ohm resistor to ground of Controlled Board.

Connect Red Led’s Anode with Pin 12 and Cathode in series with 330 ohm resistor to ground of Controlled Board.

Connect Buzzer’s Positive terminal to Pin 10 and Negative terminal to Ground of Controlled Board.

 

Planning your code –

AlgorithmFlowchart
1.   Turn ON Ultrasonic Sensor

 

2.   Check conditions such that the Distance measured should be greater than 30cm.

 

3.   If the Distance is less than equal to 30cm then turn ON red led ,Buzzer and turn OFF green led.

 

4.   If the Distance is more than 30cm then turn ON green led and turn OFF red led, Buzzer.

 

Code Implementation –

Step 0 – Here we have Ardublock software inside which we have Block Buttons , Workspace and Drag back Trash Area.

Step 1 – Inserting MAIN LOOP

1.Click on “Skdz Tasks ” button

2.Drag Out “Main Program” block

3.Place it in the Workspace Area.

 

Step 2 – Defining Ultrasonic Sensor pins

1.Click on “Skdz Robo2” button

2.Drag Out “Initialize First Ultrasonic ” block

3.Place it Inside “Setup” of  the “Main Program” block.

 

Trigger pin 14 which is pin A0 on Arduino Board and  Echo pin 15 which is pin A1 on Arduino Board with Distance 500 cm and port 1 are to be connected.

 

Step 3 –

1.Click on “Skdz Variables/Constants” button

2.Drag out “set integer variable” block

3.Place it Inside “Setup” of  the “Main Program” block as shown in image below.

Step 4 –

1.Double Click on “Integer” Tag

2.Rename text “Integer” to  “Distance” as shown in below image.

Step 5 –

1.Drag  “0” tag with “set integer variable” block to Drag Back Trash Area.

2.Click on “Skdz Robo2” button.

3.Drag “Distance US1(cm)” block .

4.Place it in “value” tag of “set integer variable” block as shown in image below.

Step 6 –

1.Click on “Skdz Control” button

2.Drag out “If/else” block 

Share This