Sound Sensor Interfacing with 8051

In our last tutorial, we have seen how to interface the Bluetooth module with 8051. This tutorial is all about Sound Sensor Interfacing with 8051.

Prerequisites

Before starting this tutorial we should know the below topics. If you know already, please go further.

Components Required

Introduction

The sound detection sensor module detects whether the sound has exceeded a threshold value. Sound is detected via microphone and fed into an LM393 op-amp. The sound level setpoint is adjusted via an onboard potentiometer. When the sound level exceeds the setpoint, an LED on the module is illuminated and the output is sent low.

Product Description

  • Main chip: LM393, electret microphone
  • Working voltage: DC 4 ~ 6V
  • Has the signal output instructions
  • Single signal output.
  • Effective signal output for low level.
  • Output low level and the signal light will on when there is a sound.
  • Can be used for the sonic lamp, with photosensitive sensors act as sound and light alarm, also can be used in the occasion of voice control and sound detection.
  • Circuit boards output switch value.

Note: This sensor only recognizes the availability of sound can not identify the size of the sound or the specific frequencies of sound.

Sound Sensor Interfacing with 8051 – Clap detecting sensor

Connection

Sound Sensor

  • Vcc – 5v
  • GND – Ground
  • Vout – P1.0

LCD

  • RS – P2.0
  • RW – P2.1
  • EN – P2.2
  • Data Lines – P3.0 – P3.7

Sound Sensor Interfacing with 8051

Source Code

If this sensor detects any sound, LCD will display “Sound Detected”. You can also vary the threshold level by adjusting the Potentiometer in that sensor module.

#include<reg51.h>
#define lcd P3
 
sbit SOUND=P1^0;
 
sbit rs=P2^0; //register select
sbit rw=P2^1; //RW
sbit en=P2^2; //enable
 
void lcd_init();
void cmd(unsigned char);
void dat(unsigned char);
void delay();
void lcd_string(char *s);
 
void main()
{
    lcd_init();
    lcd_string("  EmbeTronicX   ");
    while(1) {
        if(SOUND == 0) {
            cmd(0xc0);
            lcd_string("Sound Detected");
            delay();
        } else {
            cmd(0xc0);
            lcd_string("                ");
        }
    }
}
 
void lcd_init()
{
    cmd(0x38);
    cmd(0x0e);
    cmd(0x06);
    cmd(0x01);
    cmd(0x80);
}
 
void cmd(unsigned char a)
{
    lcd=a;
    rs=0;
    rw=0;
    en=1;
    delay();
    en=0;
}
 
void dat(unsigned char b)
{
    lcd=b;
    rs=1;
    rw=0;
    en=1;
    delay();
    en=0;
}
 
void lcd_string(char *s)
{
    while(*s) {
       dat(*s++);
     }
}
 
void delay()
{
    unsigned int i;
    for(i=0;i<20000;i++);
}

Applications

SECURITY SYSTEM FOR HOME/OFFICE

The system can be used for home /office security purposes. When a thief or robber tries to enter the home or office, some sort of sound will be generated. It may be voice or any other sort of sound. The microphone takes the sound and sends messages instantly.

CLAPPING SWITCH

The system can be used as a clapping switch. If we add the LED with a relay or BJT, the system acts as a switch. When we clapped, the microphone takes the sound, and the comparator output goes high. As a result, BJT or relay turns on. If we connect this BJT or relay with light, fan or any electrical / electronic instruments, the system can be operated as a clapping switch.

In our next tutorial, we will see a Touch sensor interfacing with 8051.

You can also read the below tutorials.

Linux Device Driver TutorialsC Programming Tutorials
FreeRTOS TutorialsNuttX RTOS Tutorials
RTX RTOS TutorialsInterrupts Basics
I2C Protocol – Part 1 (Basics)I2C Protocol – Part 2 (Advanced Topics)
STM32 TutorialsLPC2148 (ARM7) Tutorials
PIC16F877A Tutorials8051 Tutorials
Unit Testing in C TutorialsESP32-IDF Tutorials
Raspberry Pi TutorialsEmbedded Interview Topics
Reset Sequence in ARM Cortex-M4BLE Basics
VIC and NVIC in ARMSPI – Serial Peripheral Interface Protocol
Bootloader TutorialsRaspberry PI Pico Tutorials
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x