2.28 Sound Sensor Module¶
In this lesson, you will learn how to use a sound sensor module. The sound sensor module provides an easy way to detect sound and is generally used for detecting sound intensity.
In this example, we can directly connect the pin of Sound Sensor Module to the pin of Mega 2560 Board, connect the pin「G」 of Sound Sensor Module to GND, the pin 「+」to 5V, AO to analog pin A0, and D0 to digital pin 2.
You can open the file
2.28_soundSensorModule.inounder the path of
Or copy this code into Arduino IDE.
After uploading the code to the Mega2560 board, you can open the serial monitor to see the read value of the pin. When the ambient sound gets louder, the digital reading is 「1」 (adjust the potentiometer of the module to modify the threshold to trigger the high level), and the reading value of the analog pin will change significantly; when the environment is quiet, the digital reading is 「0」 and the analog reading changes smoothly.
The range of analog reading is「0」~「1023」, but influenced by the the environmental condition and the characteristics of sound sensor, the actual reading range may be smaller than the theoretical one. If an oscilloscope is used, the changing of analog reading of the sound sensor will be more obvious.