Introduction: Social Distancing Ensurer

Where I got my idea from...(Thanks guys!)

In case you were living under a rock for the past couple of months, you are most likely aware of the deadly Virus roaming the world right now. The government officials are advising everybody to keep social distances (1 meter). But I get it, keeping track of your surrounding while you are buried in your devices can be frustrating, that's why I built this system to help people with this.

Video demo


1x Arduino Leonardo

A couple of wires

1x Distance sensor

1x Speaker

1x LED Light

Step 1: How to Make the STUFF

To have the arduino board functions correctly, the wires must be inserted in the right spots in order to let this machine functions properly.
Wrong wire connections: different types of boards, such as Arduino Uno, Leonardo may have different functions under same wire connections. Therefore, before starting this project, make sure the wire connections are correct for the type of board being used. Another significant part of wire connections is not to install the incorrect connections of the wires for the positive and negative electrodes.

LED Light Bulbs: (See Above)
LED light bulbs have two pins, one is for the positive pole and one is for the negative. The positive pole should connected directly to the digital pin. The negative pole must connect to the negative electrode with a 220-ohm resistor in between in order to have the light bulbs function properly. The negative pole must be connected to the GND on the Arduino board. The negative pole can be connected to the GND port through the connection of the negative pole with the negative port of the board, which the negative port of the breadboard is connected to the GND port with a wire.

Ultrasonic Distance Sensor: (See Above)

The ultrasonic distance sensor is designed with four parts that need to be installed on the board. The four parts are: Gnd, Echo, Trig, and Vcc. Gnd needs to be installed to the negative electrode. Echo and Trig need to be installed to the digital pins. Vcc needs to be installed to the positive electrode. Gnd --> negative electrode on the board Echo --> D11 Trig --> D12 Vcc --> positive electrode on the board

The Code

**Please be aware that you do have to download 2 different add-ons, you can download them here:

Download NewTone here!

Download NewPing here!

Copy the code here!

Code Demo:

**Please be aware that you do have to download 2 different add-ons, you can download them here:



* Originally from

* * Credit goes to Brown Dog Gadgets * */



#define ECHO_PIN 6 // Arduino pin tied to echo pin on the ultrasonic sensor. #define TRIGGER_PIN 5 // Arduino pin tied to trigger pin on the ultrasonic sensor. #define MAX_DISTANCE 500 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

int theDistance = 0; int theDistanceTotal = 0; int triggerDistance = 100; // set the distance in centimeters to trigger the action int sampleVal = 5;

int speakerPin = 8; int ledPin = 9; int myTone = 500;

void setup() { Serial.begin(9600); Serial.println("Starting..."); pinMode(speakerPin, OUTPUT); pinMode(ledPin, OUTPUT); NewTone(speakerPin, myTone); delay(500); noNewTone(speakerPin); }

void loop() {

theDistance = sonar.ping_cm(); // distance sensor Serial.print("distance: "); Serial.print(theDistance); Serial.println("cm");

myTone = map(theDistance, triggerDistance, 0, 50, 500);

if ((theDistance > 1) and (theDistance < triggerDistance)) { // LED digitalWrite(ledPin, HIGH); //改 delay(10); digitalWrite(ledPin, LOW); //改 delay(10);

// Piezo NewTone(speakerPin, myTone); // reset theDistance = 0; theDistanceTotal = 0; } else {

digitalWrite(ledPin, LOW); //改 noNewTone(speakerPin);


delay(50); // delay between pings }

// end