Elegoo Official
Published

"Don't Touch Your Face" Hat

To keep yourself from unconsciously touching your face so that the virus doesn't enter your eyes, nose, and mouth from your hands.

BeginnerFull instructions provided1 hour623
"Don't Touch Your Face" Hat

Things used in this project

Hardware components

Elegoo Arduino Nano V3+
×1
Active Buzzer
×1
Slide Switch
×1
Slodering Tin
×1
9V Battery
×1
Wire
×1

Story

Read more

Schematics

"Don't Touch Your Face" Hat .jpg

Code

"Don't Touch Your Face" Hat

Arduino
#include "SR04.h"


#define TRIG_PIN 12
#define ECHO_PIN 11
long a;
SR04 sr04 = SR04(ECHO_PIN, TRIG_PIN);
int buzzer = 10;//the pin of the active


void setup() {
pinMode(buzzer,OUTPUT);//initialize the buzzer pin as an output
}


void loop() {
  a=sr04.Distance();
   if(a<=8&&a>=1)
{
for(int i=0;i<80;i++)
   {
    digitalWrite(buzzer,HIGH);
    delay(1);//wait for 1ms
    digitalWrite(buzzer,LOW);
    delay(1);//wait for 1ms
    }
  }
  digitalWrite(buzzer,LOW);


}

Credits

Elegoo Official

Elegoo Official

3 projects • 18 followers

Comments