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

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

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

Step 1: Build the Circuit

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.

Step 2: Lay Out Supplies

Lay out all the supplies listed in the supplies section.

Step 3: 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>

Step 4: Done!

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

Be the First to Share

    Recommendations

    • Summer Fun: Student Design Challenge

      Summer Fun: Student Design Challenge
    • Metal Contest

      Metal Contest
    • Maps Challenge

      Maps Challenge

    Comments