Automated Social Distancing Tin Foil Hat

by _TheLIZardWizard_ in Circuits > Wearables

717 Views, 0 Favorites, 0 Comments

Automated Social Distancing Tin Foil Hat

103403185_1098556263863480_2799639429458107548_n.jpg
103833442_254228132343360_2763436861688033987_n.jpg

Are you paranoid about catching covid? Need to get groceries

before the store closes in an hour but not looking forward to the crowds? Fear not, this hat uses and ultrasonic sensor and Arduino uno to alert you and others when they are too close and need to back away. it even rotates to makes sure you are protected from all angles (while looking fabulously ridiculous with a spinning robot on your head).

the hat is made out of mostly household materials besides the electronics and can be built in short period of time. I consider it version 1 and eventually plan to make an updated version with more permanent parts and a pir sensor.

As of now, the ultrasonic sensor sits on the rotating servo on top of the hat scanning for close objects. If someone is too close, it will light leds and make buzzing noises. The lights are places behind signs on the hat warning people to back away when they turn on. You can use more or fewer leds than the suggested depending on your preference.

Supplies

electronics:

1. Arduino Uno

2. 9g Micro Servo

3. 1K Ohm Resistor

4. 9v Battery and clip

5. Ultrasonic Sensor - HC-SR04

6. LED - Basic Yellow 5mm X2

7. LED - Basic Red 5mm x3

8. LED – Basic green 5mm

9. switch

10. 330 Ohm Resistors

11. Npn transistor

12. Passive buzzer

13. BreadBoard

14. Jumper Wires Pack - M/M

hat materials and tools:

1. 3 plastic containers

1 round head-shaped one,

one small rectangle large enough to fit the uno and breadboard, at least 4 in,

one larger rectangle that will fit over the circular container

2. Tin foil

3. Tape

4. Glue

5. Foam board

6. Paint

7. Translucent plastic sheets

8. Scissors

9. Soldering iron (optional)

2. Building the circuit

Building the Circuit

sssss.png
101883446_264968241236865_1417739936445965966_n.jpg
102930835_265374621195415_2642536540395013089_n.jpg

Most

of these parts I left on breadboards but you can solder or not solder whatever is convenient for you. I originally planned to use an Arduino nano to save space, but unfortunately, the package is still on its way. The schematic shows only one led of each color, but I attached more in parallel to go behind the warning signs in front of the hat. I also added a switch and leads to the battery to fit with the Arduino.

The Code

The ultrasonic sensor sits on top of the rotating servo so that it can scan the entire area around you. If someone is close but not too close, the yellow leds will light and a low tone buzz goes off. If they get even closer, the servo stops and the sensor focuses in on them, emitting a louder beep and lighting the red leds. Distance is calculated in cm and can be adjusted to personal preference.

#include

Servo myservo;

int servopin = 9; //servo

int pos = 0;

const int trigPin = 11; //trigger

const int echoPin = 10; //echo

int rledpin = 8; //red leds

int yledpin = 7; //yellow leds

int gledpin = 6; //green led

int buzpin = 5; //buzzer

int x;

long duration;

int distance;

void calcDistance(void);

void setup() {

// put your setup code here, to run once:

myservo.attach(servopin);

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

Serial.begin(9600);

pinMode(gledpin, OUTPUT);

pinMode(yledpin, OUTPUT);

pinMode(rledpin, OUTPUT);

digitalWrite(gledpin, HIGH);

pinMode(buzpin, OUTPUT);

}

//--------------function calculates distance and controls lights and buzzer depending on results

void calcDistance(){

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance= duration*0.034/2;

Serial.println(distance);

delay(50);

if(distance >= 300){

//ledonpin = gledpin;

Serial.println("OK");

digitalWrite(rledpin, LOW);

digitalWrite(yledpin, LOW);

}

if(distance>150 && distance<300){

//ledonpin = yledpin;

Serial.println("WARNING");

digitalWrite(rledpin, LOW);

digitalWrite(yledpin, HIGH);

tone(buzpin, 800, 1000);

delay(1000);

}

if(distance <= 150){

//ledonpin = rledpin;

Serial.println("TOO CLOSE");

digitalWrite(rledpin, HIGH);

digitalWrite(yledpin, HIGH);

tone(buzpin, 1500, 1000);

delay(1000);

if(x == 0){//if the obect is too close, the servo stops rotating until it is further away

pos = pos-15;

}

if(x==1){

pos = pos+15;

}

}

}

//----------------

void loop() {

for (pos = 0; pos <= 180; pos += 15) { //goes from 0-180 stopping every 15 degrees to calulate distance

x=0;

myservo.write(pos);

delay(100);

Serial.println(pos);

calcDistance();

delay(100);

}

for (pos = 180; pos >= 0; pos -= 15){

x=1;

myservo.write(pos);

delay(100);

Serial.println(pos);

calcDistance();

delay(100);

}

}

Make the Hat Base

101793259_560361721348053_9113526525968634183_n.jpg
102387677_334980667498353_651820171561280219_n.jpg
101874270_249469359679472_6611191639366718652_n.jpg
103534794_2321030881536722_689002044616318160_n.jpg

The hat uses three plastic tins, one to fit your head, which should probably be somewhat circular in shape, a small square one to hold the electronics, and a larger square one to display the signs over the circular tin. Use tin foil for decoration and to make the circular hat fit snug.

to make the signs:

the signs will go on the front of the hat. Take some translucent plastic (I used plastic cut out of a cat litter box) and write whatever social distancing message you want to show. Paint around the outline of the letters with light paint and when the lights turn on it will better illuminate the letters.

Prepare to Put the Circuit in the Hat

103097761_259745958451840_2691357540563674261_n.jpg
103415802_298383874884424_950706915891355650_n.jpg
101932291_287889279246726_4979499630395723981_n.jpg

First stack the battery on the Arduino, I cut out a foam board guide to hold it and keep it from touching other components.

Next place the breadboard on top, move the wires around so that everything fits neatly together, it may take some playing with. Its goot to cluster the leds in front so they are visible and leave an open space on the board for where the servo will go.

Put the Circuit in the Hat

103403196_248125843148850_5068684497830656829_n.jpg
102947398_2676318572637667_8266528688167425827_n.jpg
103833442_254228132343360_2763436861688033987_n (1).jpg
102566423_914895895641592_4242820105989583816_n.jpg
103091805_2518475078415481_1027186650516417457_n.jpg

Cut a hole in the top of the small plastic box so that the servo and leds stick out and the base of the Arduino sits on the top of the larger plastic container. Run the wires for the servo, yellow leds, red leds, and ultrasonic sensor through the hole.


Put the sensor on top of the servo. I glued a foam board guide to the servo and attached the sensor with a rubber band, although feel free to use something more permanent.

for the finishing touches, glue the signs on the front of the rectangle parts of the hat. Curve them a bit so that there is room for the leds behind them.

Wear the Hat

103403185_1098556263863480_2799639429458107548_n (1).jpg

That’s it! Put the hat on, flip the switch and look wonderfully paranoid with your glowing, beeping, automated social distancing hat!

thanks, and let me know if you have any questions, comments, or suggestions!