Antivirus Alarm - Simple Arduino Model to Ensure Social Distancing With Adjustable Distances

by Ashleyyycheng303 in Circuits > Arduino

1396 Views, 2 Favorites, 0 Comments

Antivirus Alarm - Simple Arduino Model to Ensure Social Distancing With Adjustable Distances

Antivirus Alarm - Social Distancing

Introduction

During times of global pandemics, such as the COVID-19 we’re encountering currently, social distancing, quarantine, and isolation are vital methods to keep yourself safe from viruses and to decrease the probability of being infected (Centers of Disease Control and Prevention). As the most approachable method out of all, social distancing may be the top choice for those who aim to keep their lives as unchanged as possible. While health and disease-prevention experts suggest people to keep a distance of 6 ft (2m) with others, when considering the practicality in real-life, it's merely impossible to maintain a fixed distance in all different circumstances.

Inspired by ('Don't Touch Me' Anti-Virus Alarm), the following project will demonstrate how to create an antivirus alarm with adjustable distances, granting the users to set their desirable minimum distance whenever they want.

____________________________________________

Modifications

- Two Levels of Warning: Red and Orange LEDs

(distance < min distance) (min distance < distance < min distance + .5 meters)

- Adjustable Minimum Distance

(potentiometer)

____________________________________________

Supplies

- Arduino Board *1

(The following post uses Arduino Leonardo, but other types are also usable)

- Breadboard *1

- Ultrasonic Range Finder *1

- LCD Display Board 12C *1

(The following instructions and codes will be based on 12C LCD. If your LCD display board doesn't have 12C, either purchase one with 12C or weld the display board onto Arduino.)

- Potentiometer *1

- LED Light Bulbs *8 (Red and Orange, each for 4)

- Portable Charger *1

- Resistors *2

- Wires

Build the Circuit

Incredible Sango.png
IMG_1277.JPG

Referring to the schematics above, build the circuit on your own Arduino board.

Note:

1. The 12C LCD display board isn’t shown in the first image, please refer to the second image for setting it up.

2. Although the board in the first image is Arduino Uno and the board in the second image is Arduino Leonardo, both and all other Arduino boards are applicable for this project.

Lay Out Supplies

01213_222.jpg
12002-Breadboard_-_Self-Adhesive__White_-01.jpg
2020.04.16 Arduino Antivirus Alarm Images.jpg
lcd-plus-i2c.jpg
10k ohm Variable POT Resistor Potentiometer-550x550.jpg
61s3-oWcshL._AC_SL1200_.jpg
61cbjhBLaXL._AC_SL1100_.jpg
11026-Jumper_Wires_Standard_7in._M_M_-_30_AWG__30_Pack_-01.jpg

Lay out all the supplies listed in the supplies section.

Upload Code

Please follow the link or copy-paste the code below for the project.

<p>#include <wire.h><br>#include <br></wire.h></p><p>#define ECHO_PIN     6  
#define TRIGGER_PIN  5  
#define MAX_DISTANCE 500 </p><p>int theDistance = 0;
int theDistanceTotal = 0;
int triggerDistance; 
int sampleVal = 5;
int UltrasonicSensorCM(int trigPin, int echoPin) 
{
  long duration;
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(20);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  duration = duration / 59;
  if ((duration < 2) || (duration > 200)) return false;
  return duration;
}</p><p>int speakerPin = 8;
int ledPin = 9;
int myTone = 500;</p><p>LiquidCrystal_I2C lcd_I2C_27(0x27, 16, 2); </p><p>void setup() {</p><p>  Serial.begin(9600);
  Serial.println("Starting...");
  delay(500);
  lcd_I2C_27.init (); 
  lcd_I2C_27.backlight();
  digitalWrite( 7 , LOW ); 
  pinMode( 12 , OUTPUT);   
  pinMode( 10 , OUTPUT);   </p><p>}</p><p>void loop() {</p><p>  lcd_I2C_27.init (); 
  lcd_I2C_27.backlight();</p><p>  theDistance = UltrasonicSensorCM( 7 , 6 ) ;</p><p>  // distance sensor
  Serial.print("distance: ");
  Serial.print(theDistance);
  Serial.println("cm");</p><p>  myTone = map(theDistance, triggerDistance, 0, 50, 600);</p><p>  triggerDistance = ( analogRead( A0 ) / 4 ) ;
  lcd_I2C_27.setCursor(0 , 0) ; 
  lcd_I2C_27.print( "Min Distance:" ); 
  lcd_I2C_27.setCursor(0 , 1) ; 
  lcd_I2C_27.print( triggerDistance ); </p><p>  if ( theDistance < ( triggerDistance + 50 )  &&  theDistance > triggerDistance  ) { 
    digitalWrite( 10 , HIGH ); 
  } 
  if ( theDistance < triggerDistance ) {
    digitalWrite( 12 , HIGH );  
    digitalWrite( 10 , LOW );  
  }
  if ( theDistance > triggerDistance ) {
    digitalWrite( 12 , LOW );  
  }
  if ( theDistance > ( triggerDistance + 50 ) ) { 
    digitalWrite( 12 , LOW );  
    digitalWrite( 10 , LOW );  
  } 
  lcd_I2C_27.clear(); 
  lcd_I2C_27.setCursor(0 , 0) ; 
  lcd_I2C_27.print( "Min Distance:" ); 
  lcd_I2C_27.setCursor(0 , 1) ; 
  lcd_I2C_27.print( triggerDistance ); 
  delay( 1000 ); 
}</p>

Done!

IMG_1296.jpg
IMG_1297.JPG

You now have an adjustable antivirus alarm to ensure social distancing and to keep you safer during times of epidemics and pandemics!