Simple FC-04 Sound Sensor Demo

by gr8yt in Circuits > Arduino

30197 Views, 11 Favorites, 0 Comments

Simple FC-04 Sound Sensor Demo

566cd5484936d4f0420006e4.jpeg
FC04PinOut.png

The FC-04 sound sensor module, in my opinion, is a very sensitive sound detection module for the price. Although this sensor does not provide any ability to identify specific sounds or the frequency of a sound it does do what it is supposed to - it detects sound.

The key to this sensor is the on-board potentiometer (POT) which is referenced in pic 2 above as the "sound set point adjust". Every reference I saw said that POT was for adjusting the "sensitivity". Well, naturally I assumed the "sensitivity" being adjusted was the microphone pickup, as in a GAIN control. Nope, just to mess with my head, that POT adjusts the "sensitivity" of the voltage trigger point (VTP). Meaning that it adjusts the level of voltage (internally on the pickup) required to trigger OUTPUT.

To successfully use this sensor you need to adjust that POT until you find the sweet spot for the VTP that works best with your project, in your environment. Do note that turning the POT a tiny,tiny,tiny bit to far in either direction will leave the output stuck on HIGH or LOW (not forever, just till you turn the POT back).

Another key to a better experience with this sensor is paying very close attention to any delay times in a sketch that involves this guy. If all you want to do is turn something on and off, say when you clap your hands, this isn't as big a factor. However, say you want to synchronize something to music - as with the LEDs in this project - then paying attention to delays becomes more critical. For instance to synchronize the LEDs you want to read the sensor's output value as many times as you can, as fast as you can. If things are slowed down with delays it can cause a significant amount of changes in the output value to be missed. And a great example of that is right here, in the attached sketch. There is a debugging section in the sketch that is commented out. It is commented out because it introduces a 1/2 of a second delay into the sketch. That's so hopefully you can see the values as they flash by on the serial monitor. But just that 1/2 of a second delay has a negative impact on the synchronization of those LEDs. (if you do use the debugging section REMEMBER to comment those lines back out when you are done!)

And with all of that out of the way let's get this thing working.

Setup

FC04SoundSensor.jpg
FC04.jpeg

Items you will need;

one (1) Arduino board

one (1) FC-04 Sound Sensor Module (or similar 3 pin sensor)

two (2) LEDs

two (2) 150 ohm resistors (color bands = Brown/Green/Brown)

one (1) breadboard and jumper wires

a small screwdriver (or something) to adjust the potentiometer

Setup Instructions;

HINT: When placing the sound sensor on the breadboard do so in a manner that makes it easy for you to get to the on-board POT.

1. 5v out from Arduino to positive rail on breadboard

2. GND from Arduino to ground rail on breadboard

3. connect 5v positive to Vcc in on the sensor module

4. connect ground to GND on the sensor module

5. connect analog pin #4 (A4) on Arduino to OUT on the sensor module

6. place the resistors and LEDs on your breadboard

6a. connect the positive leg of one LED to one leg of a resistor

6b. connect the positive leg of the other LED to one leg of the other resistor

7. connect digital pin #2 to a resistor on the opposite leg from the LED

8. connect digital pin #4 to the other resistor in the same manner

9. connect the negative legs of both LEDs to ground

And I believe that does it for setting this up. Shall we move on to some code for this? And guess what is coming up in the next step!

Code

FC04ScreenShot.JPG

The sketch below is not commented, because the attached file is HEAVILY commented. You can automatically load the attached file to the Arduino interface simply by double clicking on it.

// FC-04 Sound Sensor

const int SenOut = A4;

const int LED1 = 2;

const int LED2 = 4;

int sensorValue = 0;

void setup()
{

pinMode(LED1, OUTPUT);

pinMode(LED2, OUTPUT);

pinMode(SenOut, INPUT);

Serial.begin(9600);

void loop()
{

sensorValue = analogRead(SenOut);

if (sensorValue > 850)

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, LOW);

}

else if (sensorValue < 950)

{

digitalWrite(LED2, HIGH);

digitalWrite(LED1, LOW);

delay(50);

}

// Debugging below (un-comment to use)

// Serial.println(sensorValue);

// Serial.println();

// delay(500);

}

Again, for a ton of information regarding the above sketch (and more) please refer to the attached .ino file.

Specifications and a Treat

566db68e67400c9134000e1d.jpeg
SoundSensorB

SPECIFICATIONS:

Detection Ability - detects sound waves but does not recognize particular sounds nor the frequency of a sound.

Working Voltage - 3.3 - 6 V

Output - single channel Digital - (output remains HIGH (5v) until it's pulled LOW when sound is detected)

Note: Even though the output is digital, either HIGH or LOW, this little guy responds fast enough so that you can still use different voltage levels to make things happen in your sketch. What I'm trying to say hear is that when the sensor picks up a sound vibration it will begin to bring it's output low. But, those sound vibrations move so fast and this guy responds so fast, that it may be in the process of pulling the output LOW when the vibration(s) stop and the sensor runs the output HIGH again. So the voltage may have only dropped from HIGH (5v) to 3.5v before it was brought back to 5v again. And we can take advantage of that in our sketches.

Adjustable Sensitivity - via on-board POT (potentiometer) - This adjusts the OUTPUT voltage trigger point (how much sound is required before the sensor triggers the OUTPUT pin. Adjusting this POT to high will cause the OUTPUT to remain HIGH, to low and OUTPUT will remain LOW. Finding the "sweet spot" where the module responds as desired can be tricky.

Pins on Module - three (3), VCC / GND / OUTisOn-Board LEDs - Red LED, power indicator Green LED, on when sound is detected

Dimensions: 1.73 x 0.63 x 0.35 (inches)

AND YOUR TREAT

Of course I couldn't leave this alone. Above is a pic of my wiring for ten (10) LEDs responding to the sound sensor. The LEDs are wired into five groups, with two LEDs in each group. I included a video of those LEDs in action. Hope you like Tina Turner (Rollin on the River).

As always, thank you for reading this and if you found any errors or omissions please do not be shy about telling me. I'd much rather fix something than leave an error floating around to mess someone up.