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.
Components and supplies
1
PIR Sensor, 7 m
1
Buzzer
1
Temperature Sensor
1
Arduino UNO
1
Alphanumeric LCD, 16 x 2
1
Breadboard (generic)
1
Resistor 1k ohm
1
LED (generic)
Apps and platforms
1
Arduino IDE
1
Tinkercad
Project description
Code
Automatic social distancing
c_cpp
1#include <LiquidCrystal.h> 2 3LiquidCrystal lcd(10,9, 5, 4, 3, 2); 4 5int sensorPin = 0; 6int buzzerPin = 12; //BUZZER INPUT PIN. 7int ultrasonicpin=6; 8int sensorvalue=LOW; 9int pirPin = 13; 10int ledPin = 11; 11int sensorpin; 12void setup() 13{ 14 lcd.begin(16, 2); 15 pinMode(buzzerPin, OUTPUT); //SET BUZZER AS OUTPUT. 16 pinMode(ledPin, OUTPUT); //SET LED AS OUTPUT. 17 pinMode(pirPin, INPUT); //SET PIR AS INPUT. 18 pinMode(A0, INPUT); 19} 20void loop() 21{ 22 lcd.clear(); 23int reading = analogRead(sensorPin); 24float voltage = reading * 5.0; 25voltage /= 1024.0; 26float temperatureC = (voltage - 0.5) * 100 ; 27float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0; 28if(temperatureC>=38.0) 29{ 30 sensorvalue = digitalRead(pirPin); //READ PIR INPUT PIN. 31 if( sensorvalue == HIGH ) { //IF MOTION IS DETECTED. 32 tone(buzzerPin, 1200); //BUZZ THE BUZZER. 33 digitalWrite(ledPin, HIGH); //ON LED. 34 delay(100); //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF). . 35 lcd.setCursor(1,0); 36 lcd.print("Social distanci"); 37 lcd.setCursor(0,1); 38 lcd.print("ng is violated"); 39 delay(100); //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF). 40 } 41 else{ 42 noTone(buzzerPin); //SILENT THE BUZZER. 43 digitalWrite(ledPin, LOW); 44 lcd.print("You have fever!!"); 45 lcd.setCursor(0,1); 46 lcd.print("C="); 47 lcd.print(temperatureC); 48 lcd.print(" F="); 49 lcd.print(temperatureF);} 50}else{ 51 sensorvalue = digitalRead(pirPin); //READ PIR INPUT PIN. 52 if( sensorvalue == HIGH ) { //IF MOTION IS DETECTED. 53 tone(buzzerPin, 1200); //BUZZ THE BUZZER. 54 digitalWrite(ledPin, HIGH); //ON LED. 55 delay(100); //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF). . 56 lcd.setCursor(1,0); 57 lcd.print("Social distanci"); 58 lcd.setCursor(0,1); 59 lcd.print("ng is violated"); 60 delay(100); //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF). 61 } 62 else{ 63 noTone(buzzerPin); //SILENT THE BUZZER. 64 digitalWrite(ledPin, LOW); 65 lcd.print("You are safe"); 66 lcd.setCursor(0,1); 67 lcd.print("C="); 68 lcd.print(temperatureC); 69 lcd.print(" F="); 70 lcd.print(temperatureF); 71 digitalWrite(9,0); 72 } 73 } 74 delay(1000); 75 }
Automatic social distancing
c_cpp
1#include <LiquidCrystal.h> 2 3LiquidCrystal lcd(10,9, 5, 4, 3, 2); 4 5int 6 sensorPin = 0; 7int buzzerPin = 12; //BUZZER INPUT PIN. 8int 9 ultrasonicpin=6; 10int sensorvalue=LOW; 11int pirPin = 13; 12int ledPin = 11; 13int 14 sensorpin; 15void setup() 16{ 17 lcd.begin(16, 2); 18 pinMode(buzzerPin, OUTPUT); 19 //SET BUZZER AS OUTPUT. 20 pinMode(ledPin, OUTPUT); //SET 21 LED AS OUTPUT. 22 pinMode(pirPin, INPUT); //SET PIR AS INPUT. 23 24 pinMode(A0, INPUT); 25} 26void loop() 27{ 28 lcd.clear(); 29int 30 reading = analogRead(sensorPin); 31float voltage = reading * 5.0; 32voltage 33 /= 1024.0; 34float temperatureC = (voltage - 0.5) * 100 ; 35float temperatureF 36 = (temperatureC * 9.0 / 5.0) + 32.0; 37if(temperatureC>=38.0) 38{ 39 sensorvalue 40 = digitalRead(pirPin); //READ PIR INPUT PIN. 41 if( sensorvalue == HIGH 42 ) { //IF MOTION IS DETECTED. 43 tone(buzzerPin, 1200); //BUZZ 44 THE BUZZER. 45 digitalWrite(ledPin, HIGH); //ON LED. 46 delay(100); 47 //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF). . 48 49 lcd.setCursor(1,0); 50 lcd.print("Social distanci"); 51 lcd.setCursor(0,1); 52 53 lcd.print("ng is violated"); 54 delay(100); //TIME 55 DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF). 56 } 57 else{ 58 noTone(buzzerPin); 59 //SILENT THE BUZZER. 60 digitalWrite(ledPin, LOW); 61 62 lcd.print("You have fever!!"); 63 lcd.setCursor(0,1); 64 lcd.print("C="); 65 66 lcd.print(temperatureC); 67 lcd.print(" F="); 68 lcd.print(temperatureF);} 69}else{ 70 71 sensorvalue = digitalRead(pirPin); //READ PIR INPUT PIN. 72 if( sensorvalue 73 == HIGH ) { //IF MOTION IS DETECTED. 74 tone(buzzerPin, 1200); 75 //BUZZ THE BUZZER. 76 digitalWrite(ledPin, HIGH); //ON 77 LED. 78 delay(100); //TIME DIFFERENCE BETWEEN HIGH(ON)& 79 LOW(OFF). . 80 lcd.setCursor(1,0); 81 lcd.print("Social 82 distanci"); 83 lcd.setCursor(0,1); 84 lcd.print("ng is violated"); 85 86 delay(100); //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF). 87 88 } 89 else{ 90 noTone(buzzerPin); //SILENT THE BUZZER. 91 92 digitalWrite(ledPin, LOW); 93 lcd.print("You are safe"); 94 lcd.setCursor(0,1); 95 96 lcd.print("C="); 97 lcd.print(temperatureC); 98 lcd.print(" F="); 99 100 lcd.print(temperatureF); 101 digitalWrite(9,0); 102 } 103 } 104 delay(1000); 105 106 }
Downloadable files
Automatic social distancing
Automatic social distancing

Comments
Only logged in users can leave comments