Home > Basic Circuits >Sensor Circuits > Build a musical fountain using Arduino and sound sensor

Build a musical fountain using Arduino and sound sensor

Source: InternetPublisher:笑流年 Keywords: Arduino Sound Sensor Updated: 2024/12/27

    There are several fountains that can sprinkle water unconditionally with some interesting light effects. So I want to design an innovative fountain that can respond to external music and sprinkle water according to the beat of the music. Doesn't it sound interesting?

    The basic idea of ​​this Arduino fountain is to take input from any external sound source like mobile, iPod, PC etc., sample the sound and break it down into different voltage ranges and then use the output to turn on various relays. We first use a condenser microphone based sound sensor module to perform on the sound source to separate the sound into different voltage ranges. The voltage will then be fed to an operational amplifier to compare the sound level with a specific limit. The higher voltage range will correspond to the relay switch turning on which consists of a musical fountain that runs according to the beat and rhythm of the song. So here we are building this musical fountain using Arduino and sound sensor.

    Required Materials

    Arduino Nano

    Sound sensor module

    12V Relay Module

    DC Pumps

    Light Emitting Diode

    Connection lines

    Vero board or breadboard

    Working of Sound Sensor

poYBAGMHI1uAV9npAALwIKunwhA540.png

    The Sound Sensor Module is a simple electret microphone based electronic board used to sense external sounds from the environment. It is based on the LM393 power amplifier and an electret microphone and can be used to detect if there is sound exceeding the set threshold limit. The module output is a digital signal indicating whether the sound is greater or less than the threshold.

The potentiometer can be used to adjust the sensitivity of the sensor module. When the sound source is below/above the threshold set by the potentiometer, the module output is HIGH/LOW. The same sound sensor module can also be used to measure the sound level in decibels.

    Sound sensor circuit diagram

pYYBAGMHI1aADTT_AACmGougL_o683.png

    As we all know, in the sound sensor module, the basic input device is a microphone, which converts the sound signal into an electrical signal. But since the electrical signal output amplitude of the sound sensor is very small and difficult to analyze, so we have used an NPN transistor amplifier circuit to amplify it and feed the output signal to the non-inverting input of the Op-amp. Here the LM393 OPAMP is used as a comparator to compare the electrical signal from the microphone with the reference signal from the voltage divider circuit. If the input signal is greater than the reference signal, the output of the OPAMP will be high, and vice versa.

    Music fountain circuit diagram

poYBAGMHI1CAeknDAAE8qOUcC4I591.png

    As shown in the above music fountain circuit diagram, the sound sensor is powered by the 3.3V power supply of Arduino Nano, and the output pin of the sound sensor module is connected to the analog input pin (A6) of Nano. You can use any analog pin, but make sure to change it in the program. As shown in the figure, the relay module and DC pump are powered by an external 12VDC power supply. The input signal of the relay module is connected to the digital output pin D10 of Nano. For the lighting effect, I chose two LEDs of different colors and connected them to the two digital output pins (D12, D11) of Nano.

    Here, the pump is connected in such a way that when a high pulse is received at the input of the relay module, the COM contact of the relay is connected to the NO contact and the current gets a closed path to flow through the pump to activate the water flow. Otherwise the pump remains off. The high/low pulses are generated by the Arduino Nano depending on the sound input.

    After soldering the complete circuit on the perfboard it will look like this:

pYYBAGMHI0yAcjwIAAb0AVpDOTI845.png

    Here we use a plastic box as a fountain container and a mini 5v pump as a fountain, we used this pump before in the fire robot:

poYBAGMHI0iAKunHAAjriH5bRG8697.png

    Programming an Arduino Nano for a Dancing Fountain

    The complete program for this Arduino Fountain Project is given at the bottom of the page. But here I am just explaining it part by part for better understanding:

    The first part of the program is to declare the necessary variables to assign the pin numbers we will use in the next program block. Then a constant REF is defined whose value is the reference value of the sound sensor module. The assigned value 700 is the byte equivalent of the sound sensor output electrical signal.

int sensor = A6;
int redled = 12; 
int greenled = 11; 
int pump = 10;

#define REF 700

    In the void setup function, we use the pinMode function to assign the INPUT/OUTPUT data direction of the pins. Here the sensor is used as input and all other devices as output.

void setup()
{ 
  pinMode(sensor, INPUT);
  pinMode(red,output);
  pinMode(green, OUTPUT);
  pinMode(PUMP, OUTPUT);
}

    In the infinite loop, the analog read function is called which reads the analog value coming in from the sensor pin and stores it in the variable sensor_value.

int sensor_value = analogRead(sensor);

    In the last part, the input analog signal is compared with the reference value using an if-else loop. If it is greater than the reference value, then all the output pins are given a high level output so that all the LEDs and pumps are activated, otherwise everything remains off. Here, we have also given a delay of 70 milliseconds to differentiate the on/off time of the relay.

if (sensor_value>REF) 
  { 
    digitalWri

pYYBAGMHI0OAa-LDAAjhvQe_TyQ079.png

poYBAGMHIz6Aabl_AAUV0xUs_7w123.png

    int sensor = A6;

int redled = 12;

int greenled = 11;

int pump = 10;


#define REF 700


void setup()

{

pinMode(sensor,INPUT);

pinMode(redled,OUTPUT);

pinMode(greenled,OUTPUT);

pinMode(pump,OUTPUT);



}

void loop()

{



int sensor_value = analogRead(sensor);



if (sensor_value > REF)

{ digitalWrite(

greenled,HIGH); digitalWrite(pump,HIGH); delay(70); } else { digitalWrite(greenled,LOW); digitalWrite(redled,LOW); digitalWrite(pump,LOW); delay(70); } }























EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号