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
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
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
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:
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:
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
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);
}
}
- What is an ac to dc transformer in circuit design
- How do Zener diodes protect circuits?
- Advantages and disadvantages of organic semiconductors, the conductive mechanism of organic semiconductors
- What are the classifications of filters?
- How to Build a Simple Temperature Indicator Circuit Using NTC and PTC Thermistors
- How to build a drag racing timer circuit using a 7-segment display and discrete components
- Share a Motorola amplifier circuit
- Simple LED advertising light circuit
- Circuit diagram of a differential amplifier circuit
- Phase-locked Frequency Multiplier(9316)
- 555 square wave oscillation circuit
- 555 photo exposure timer circuit diagram
- Introducing the CD4013 washing machine timer circuit diagram
- Simple level conversion circuit diagram
- 555 electronic guide speaker circuit diagram for blind people
- Circuit diagram of disconnection alarm composed of 555
- Analog circuit corrector circuit diagram
- color discrimination circuit
- Color sensor amplification circuit
- Level indication circuit