Introduction: Arduino Hands-free Buzzer

Hello people from the world! It is I, Sreecharan Chakka, a 7th grader from the planet earth.

All of you used a buzzer before in your life right? You press on the big red button and it buzzes for you. Well, during this situation, that kind of buzzer is not a good idea if lots of people are touching it like the buzzers that are used in Jeopardy! That is why I created this: Hands-free buzzer made with Arduino.

All the materials needed:

Step 1: Making the Circuit

First, we have to build the circuit. Here is the wiring:

  1. Ultrasonic Sensor #1: VCC-5V; TRIG-10; ECHO-9; GND-GND
  2. Ultrasonic Sensor #2: VCC-5V; TRIG-3; ECHO-4; GND-GND
  3. LED #1: Anode/Positive-2; Cathode/Negative-GND(with resistor)
  4. LED #2: Anode/Positive-8: Cathode/Negative-GND(with resistor)
  5. Buzzer: Positive-7; Negative-GND

That's all the wiring. Phew!

Step 2: Adding the Code!

The code is very simple. When the object is 10 cm above the ultrasonic sensors, the led will light up and the buzzer will buzz.

Here is the code:

#define trigPin 10

#define echoPin 9

#define trigPin2 3

#define echoPin2 4

#define led 8

#define led2 2

#define buzzer1 7

void setup(){

  Serial.begin (9600);

  pinMode(trigPin, OUTPUT);

  pinMode(echoPin, INPUT);

  pinMode(led, OUTPUT);

  pinMode(trigPin2, OUTPUT);

  pinMode(echoPin2, INPUT);

  pinMode(led2, OUTPUT);

  pinMode(buzzer1, OUTPUT);

}

void loop(){

  long duration1, distance1;

  digitalWrite(trigPin, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);

  duration1 = pulseIn(echoPin, HIGH);

  distance1 = (duration1/2) / 29.1;

  if (distance1 < 10){

    digitalWrite(buzzer1, HIGH);

    digitalWrite(led,HIGH);

    delay(2000);

    digitalWrite(buzzer1, LOW);

  }

  else {

    digitalWrite(led,LOW);

  }

  Serial.print(distance1);

  Serial.println(" cm");

  delay(500);

  // you don't actually need the serial print. Either way it works with or without the serial print

  long duration2, distance2;

  digitalWrite(trigPin2, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin2, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin2, LOW);

  duration2 = pulseIn(echoPin2, HIGH);

  distance2 = (duration2/2) / 29.1;

  if (distance2 < 10){

    digitalWrite(buzzer1, HIGH);

    digitalWrite(led2,HIGH);

    delay(2000);

    digitalWrite(buzzer1, LOW);

  }

  else {

    digitalWrite(led2,LOW);

  }

  Serial.print(distance2);

  Serial.println(" cm");

  delay(500);

}

Step 3: We Are Done!

We are done! Now you can use a hands-free buzzer to avoid contact with an actual buzzer!

Hope you liked this project. If you have any questions, just post it in the comments. Until then, stay safe and goodbye!

"Can't Touch This" Family Contest

Participated in the
"Can't Touch This" Family Contest