• Sun. Oct 24th, 2021
    • Introduction: In this project, we will learn about a new Sensor called Sound Sensor or Sound Detector. Also, I will show you how to interface a Sound Sensor with Arduino and implement a Relay control project using Arduino, Sound Sensor and a Relay Module. In this project, I will be using a different Sound Sensor (although the idea is the same), which is sensitive to sounds like loud voices, claps, snaps, thuds and taps.
    • Materials:
      • Sound Sensor Module
      • Arduino UNO
      • Relay Module (5V)
      • LED 
      • Connecting Wires
      • Mini Breadboard
    • How to Make:
    Circuit Diagram
      • Connect VCC and GND of the sound sensor to +5V and GND of Arduino. Connect the OUT pin of the Sensor to Digital I/O pin 6 of Arduino UNO. Finally, connect relay module is connected to digital I/O pin 13 of Arduino.
      • Warning: If you intend to you your relay to actually control an electrical device, be extremely careful when making the AC Mains connections.

    CODE

    const int relayPin = 7;
    const int soundPin = 6;
    
    int soundVal = 0;
    int relayToggle = LOW;
    int previousState = HIGH; 
    
    void setup ()
    {
      pinMode (relayPin, OUTPUT);
      pinMode (soundPin, INPUT);
    }
     
    void loop ()
    {
      soundVal = digitalRead(soundPin);
      if (soundVal == LOW && previousState==HIGH)
      {
        relayToggle=!relayToggle;
        digitalWrite (relayPin, relayToggle);
      
      }
      previousState=soundVal;
    }
    

    Here You Go ……

    Leave a Reply

    Your email address will not be published. Required fields are marked *