aryamansingh207lakshyabajaj14vinodpuniaaearjunshelat
Published

SD-Card (Social Distancing ICard)

A device that maintains social distancing, this device buzzes when a person is 6 feet or less away from you..

BeginnerFull instructions provided1,072
SD-Card (Social Distancing ICard)

Things used in this project

Hardware components

Buzzer, Piezo
Buzzer, Piezo
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Arduino Nano R3
Arduino Nano R3
×1
9V battery (generic)
9V battery (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
9V Battery Clip
9V Battery Clip
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

SD-Card CAD

Schematics

nano_final_SVFz05THde.png

Code

SD- Card Code

C/C++
The code on which the SD-CARD works on.
# define buz 2
#include <Servo.h>
Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position


int dis = 0;

long readUltrasonicDistance(int triggerPin, int echoPin)
{
  pinMode(triggerPin, OUTPUT);  // Clear the trigger
  digitalWrite(triggerPin, LOW);
  delayMicroseconds(2);
  // Sets the trigger pin to HIGH state for 10 microseconds
  digitalWrite(triggerPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin, LOW);
  pinMode(echoPin, INPUT);
  // Reads the echo pin, and returns the sound wave travel time in microseconds
  return pulseIn(echoPin, HIGH);
}

void setup()
{
  pinMode(8, OUTPUT); //defines pins as input or output 
  pinMode(6, OUTPUT);
  pinMode(buz, OUTPUT);
  myservo.attach(12);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  dis = 0.01723 * readUltrasonicDistance(13, A0);// testing if distance is less than 6 feet
  if (dis < 182) {
    digitalWrite(8, HIGH);
    digitalWrite(6, LOW);
    tone(buz,60);
  } else {
    digitalWrite(8, LOW);
    digitalWrite(6, HIGH);
    noTone(buz);
  }
  delay(10); // Delay a little bit to improve simulation performance
}

Credits

aryamansingh207

aryamansingh207

2 projects • 4 followers
lakshyabajaj14

lakshyabajaj14

2 projects • 4 followers
vinodpuniaae

vinodpuniaae

1 project • 4 followers
arjunshelat

arjunshelat

2 projects • 3 followers

Comments