Fighting Germs

Enter Your Electronics & Design Project for a chance to win an $200 Shopping cart of product!

Submit an EntrySubmit an Entry  Back to homepage
Project14 Home
Monthly Themes
Monthly Theme Poll


Keeping social distance and wearing a mask greatly reduce the risk to transmit/receive coronavirus.


While our attentions are usually focused on other tasks, we (or others) may need a reminder to stay 6 feet apart.


This hat looks for an object within 6 feet of the wearer. If an object approaches within 6 feet of the wearer, my voice will announce "please respect a 6 foot distancing"

If an object is within 2 feet of the hat wearer, the hat sets off a 90 dB horn for 1 second to get their attention.  nyuk nyuk nyuk

The electronics platform rotates to detect objects 360 degrees of the wearer - No Sneaking UP on the wearer from behind !  :-) 


Using the ISD1820 sound recorder chip allows instant re-recording of the message should it need to be changed quickly to a different language, or make the message multi-lingual.

The social distancing hat is clearly marked around its circumference to respect a 6 foot distance.


The hat in action can be seen on this video:









Future Modifications:

1) I'd like to get a modified PixyCam2 that could detect IR images.

This would allow the control to distinguish close objects and people, and add important features:.

An infared PixyCam2 would allow the ping sensor  to be put on a tilt/pan device to get a distance reading at a specific infared target.

It would allow accurate annunciation from a standing position as well as a sitting position.

2)  I'd like to use a better speaker to improve audio intelligibility

3) This packaging is awkward and spread out. A next prototype would be compact , lower center of gravity, and attractive.  

4) The turntable motor is mounted on top of the hat, with electronics on a platform riding on a bearing

   Next prototype version, the motor would be on the rotating platform.

   This allows the use of one battery, and the turntable motor could be temporarily stopped when an object is detected




/// SocialDIstanceHat.ino

//// setup needed VARS --------------------------

    // pinging VARs

    unsigned long Pingmicroseconds =0;

    unsigned long PingDistanceInches =0;

    int PreviousPingDistanceInches;


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

      unsigned int Ping_cm; // ping distance in cm

      int loopNR=0; // generic register for loops


void setup(){

//  Serial.begin(9600);

    pinMode(2,OUTPUT);   // Edge trigger output to ISD1820 to play a voice message

    pinMode(3,OUTPUT);   // Ping trigger

    pinMode(4,INPUT);   //  Ping echo

    pinMode(6,OUTPUT);   // Turn on LED flasher module

    pinMode(7,OUTPUT);   // Turn on turntable motor

    digitalWrite(2, LOW);

    digitalWrite(3, LOW);

    digitalWrite(6, LOW);

    digitalWrite(7, LOW);



void PING ()


   digitalWrite(3, HIGH);   // HC-SR04   pulse high TRIGGER

    delayMicroseconds(10);        // pauses for 10 microseconds

    digitalWrite(3, LOW);    // sets the TRIGGER pin off         


    // ECHO PIN measure microseconds taken to hear pulse, third number is wait time in microseconds( unsigned long int 0 to 4,294,967,295)

    Pingmicroseconds = pulseIn(4, HIGH, 13000);

    PingDistanceInches = (Pingmicroseconds/149); //formula from HC-SR04 spec sheet   , assume solution is an integer


   if (PingDistanceInches<=9){PingDistanceInches = 543;}   ///just for troubleshooting

   if (PingDistanceInches==0){PingDistanceInches = 12345;}  //just for troubleshooting


      // 340 meters/ second  * (39.37 inches per meters) =13385. inches per usec = .0133856 inches per microsecond;; 74.7 usecs/inch , multiply by 2 for send/return path

      // test and debug

      //    Serial.print("PingDistance=");

      ////    Serial.print(PingDistanceInches);

      // Serial.print("inches ");

      //   Serial.println();



void loop()



  if ((PingDistanceInches<72)&&(PingDistanceInches>24))


     digitalWrite(2,HIGH);// edge trigger audio module

     digitalWrite(6,HIGH);// turn on LED flasher relay

     delay (200);

     digitalWrite(2,LOW);// edge trigger audio module

     delay(8000); //allow 8 seconds for the audio track to finish

     digitalWrite(6,LOW);// turn off LED flasher relay


  if (PingDistanceInches<=24) ////less than 9 inches the pingdistance will be set to 543


     digitalWrite(7,HIGH);// turn on siren

     digitalWrite(6,HIGH);// turn on LED flasher relay

     delay (1000);

     digitalWrite(7,LOW);// turn off siren

     digitalWrite(6,LOW);// turn off LED flasher relay


//if ping distance is greater than 65 inches, do nothing

delay(100); //give ping some time to rest


       // Serial.print ("RunByIRRemote flag= ");

     //   Serial.println (RunByIRRemote);

     //    Serial.print ("LeftSPD = ");

     //   Serial.println (LeftSPD);