pavan_n
Published © GPL3+

Automatic SocialDistancing using pirsensor and temp with LCD

This project is helps to maintain social distancing using pir sensor and temperature sensor with LCD display.

BeginnerShowcase (no instructions)334
Automatic SocialDistancing using pirsensor and temp with LCD

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
LED (generic)
LED (generic)
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×1
PIR Sensor, 7 m
PIR Sensor, 7 m
×1
Temperature Sensor
Temperature Sensor
×1
Buzzer
Buzzer
×1
Resistor 1k ohm
Resistor 1k ohm
×1

Software apps and online services

Tinkercad
Autodesk Tinkercad
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Automatic social distancing

Code

Automatic social distancing

C/C++
#include <LiquidCrystal.h>

LiquidCrystal lcd(10,9, 5, 4, 3, 2);

int sensorPin = 0; 
int buzzerPin = 12;               //BUZZER INPUT PIN.
int ultrasonicpin=6;
int sensorvalue=LOW;
int pirPin = 13;  
int ledPin = 11;
int sensorpin;
void setup()
{
  lcd.begin(16, 2);
  pinMode(buzzerPin, OUTPUT);               //SET BUZZER AS OUTPUT.
  pinMode(ledPin, OUTPUT);                  //SET LED AS OUTPUT.
  pinMode(pirPin, INPUT);                  //SET PIR AS INPUT.
  pinMode(A0, INPUT);
} 
void loop()                     
{
    lcd.clear();
int reading = analogRead(sensorPin);  
float voltage = reading * 5.0;
voltage /= 1024.0; 
float temperatureC = (voltage - 0.5) * 100 ; 
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
if(temperatureC>=38.0)
{
  sensorvalue = digitalRead(pirPin);        //READ PIR INPUT PIN.
  if( sensorvalue == HIGH ) {               //IF MOTION IS DETECTED.
    tone(buzzerPin, 1200);                  //BUZZ THE BUZZER.
    digitalWrite(ledPin, HIGH);             //ON LED.
    delay(100);                            //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF).                      .
    lcd.setCursor(1,0);
    lcd.print("Social distanci");
    lcd.setCursor(0,1);
    lcd.print("ng is violated");
    delay(100);                        //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF).
  }
  else{
     noTone(buzzerPin);                      //SILENT THE BUZZER.
    digitalWrite(ledPin, LOW); 
    lcd.print("You have fever!!");
    lcd.setCursor(0,1);
    lcd.print("C=");
    lcd.print(temperatureC);
    lcd.print(" F=");
    lcd.print(temperatureF);}
}else{
     sensorvalue = digitalRead(pirPin);        //READ PIR INPUT PIN.
  if( sensorvalue == HIGH ) {               //IF MOTION IS DETECTED.
    tone(buzzerPin, 1200);                  //BUZZ THE BUZZER.
    digitalWrite(ledPin, HIGH);             //ON LED.
    delay(100);                            //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF).                      .
    lcd.setCursor(1,0);
    lcd.print("Social distanci");
    lcd.setCursor(0,1);
    lcd.print("ng is violated");
    delay(100);                        //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF).
  }
  else{
     noTone(buzzerPin);                      //SILENT THE BUZZER.
    digitalWrite(ledPin, LOW); 
    lcd.print("You are safe");
    lcd.setCursor(0,1);
    lcd.print("C=");
    lcd.print(temperatureC);
    lcd.print(" F=");
    lcd.print(temperatureF);
    digitalWrite(9,0);
  }
  }
  delay(1000);
  }

Credits

pavan_n
1 project • 0 followers

Comments