allekartikritvikalleanjankl2k
Created August 30, 2020

The Social Distancer

Our project is a wearable device that can clip onto your shirt and will detect if people are within 6 feet of you

The Social Distancer

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Gikfun Mini Breadboard
×1
PIR Sensor, 7 m
PIR Sensor, 7 m
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Battery, 9 V
Battery, 9 V
×1
Snap-on Connector, For 1 9-V Battery
Snap-on Connector, For 1 9-V Battery
×1
Mini USB to DC Power Adapter
×1
Stainless Steel Clips
×1
Assorted DuPont Wires
×1

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Tape, Electrical
Tape, Electrical
Scissor, Electrician
Scissor, Electrician

Story

Read more

Code

intSensorsNano.ino

C/C++
const int trigPin = 3;
const int echoPin = 4;
const int pirPin = 5;
const int oPin = 2;

void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT); 
  pinMode(echoPin, INPUT);
  pinMode(pirPin, INPUT_PULLUP);
  pinMode(oPin, OUTPUT);
}

void loop() {
  long duration, inches, cm;

  digitalWrite(oPin, LOW);
  digitalWrite(trigPin, LOW);
  delayMicroseconds(10);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  
  duration = pulseIn(echoPin, HIGH);

  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  
  int pirInput = digitalRead(pirPin);
  if(pirInput && inches < 72) {
    digitalWrite(oPin, HIGH);
    Serial.print("in range ");
    Serial.print(inches);
    Serial.println("in\n");
  }
  
  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();

  delay(100);
}

long microsecondsToInches(long microseconds) {
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds) {
  return microseconds / 29 / 2;
}

Credits

allekartik

allekartik

1 project • 0 followers
ritvikalle

ritvikalle

1 project • 0 followers
anjankl2k

anjankl2k

1 project • 0 followers

Comments