akkimsettichandu
Created August 2, 2020

sensor mask security (sms)

Iot based mask to detect and avoid hands to touch the face.

sensor mask security (sms)

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
IR receiver (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Schematics

Ultrasonic Sensor Connection

IR sensor Connection

Code

Sensor Mask Security

Arduino
int trigPin = 9;
int echoPin = 10;
int led = 13;
int ir1=8;
int ir2=7;

int val1=0;
int val2=0;
void setup() {
  Serial.begin(9600); 
   pinMode(led, OUTPUT);
   pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(ir1, INPUT);
  pinMode(ir2, INPUT);
  // put your setup code here, to run once:

}

void loop() {
  long duration, distance;
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration=pulseIn(echoPin, HIGH);
  distance =(duration/2)/29.1;
  Serial.print(distance);
  Serial.println("CM");
  delay(10);
 val1=digitalRead(ir1);
 val2=digitalRead(ir2);
 if((distance<=20)) 
  {
    digitalWrite(led, HIGH);
}
   else if(distance>20)
 {
     digitalWrite(led, LOW);
   }
if(val1==1)
{
       digitalWrite(led, HIGH);
}
if(val2==1)
{
       digitalWrite(led, HIGH);
}
else
{
  digitalWrite(led,LOW);
}
}

Credits

akkimsettichandu

akkimsettichandu

2 projects • 1 follower

Comments