Arduino Hands-free Buzzer

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

Be the First to Share

    Recommendations

    • Organization Contest

      Organization Contest
    • Rocks, Gems, and Stones Speed Challenge

      Rocks, Gems, and Stones Speed Challenge
    • Halloween Contest

      Halloween Contest

    7 Comments

    0
    labdude
    labdude

    Question 1 year ago

    So, I read through your description, but without a thorough examination of the code (difficult, because it was flattened and unformatted), I can't figure out why you need two distance sensors?
    BTW, I'am experimenting with an Arduino myself, but haven't gotten to working with the ultrasonic sensor yet. Can you suggest any good motivating exercises (besides measuring the distance to household construction eg. walls, hallways etc.)

    0
    Messi732
    Messi732

    Answer 1 year ago

    Sorry for the unformatting. I formatted it now and I added a file so you can download the code. I will try to find some exercises for you. Is that ok?

    0
    labdude
    labdude

    Reply 1 year ago

    I read through your code, and it made me think - have you tried to do anthing with doppler sensing to detect speed? You send out an 8 pulse 'chirp' if you know the freq of the chirp, and can determine the frequency of the return, you can tell if something is moving closer or farther away, and mathematically derive the speed as well.
    Might be a fun exercise...

    0
    labdude
    labdude

    Reply 1 year ago

    Sweet! Many Thanks.

    0
    Messi732
    Messi732

    Reply 1 year ago

    Thanks!