In this tutorial, we will be using the big sound sensor. We are going to program our Surilli with a basic program, so whenever a sound is detected, you can perform different tasks from its output.
Big Sound Sensor (KY-038):This sensor can detect sound and outputs, both as analog signal as well as digital, for example, when creating a clap on/clap off light switch. This sensor is very useful with the relay module.
- A0 = Analog pin
- G = Ground
- + = VCC
- D0 = Digital
In this tutorial, we will be using digital output.
Step 1: Setup Arduino IDE for SurilliMake sure you have selected the right port, board and processor for the Surilli as shown in the picture below, and that it is programmable. (Compile and upload “Blink” from File>Examples>Digital>Blink onto your Surilli to check if everything is working fine.)
Step 2: The CircuitryThe circuitry is very simple. Follow the figure to setup your hardware.
int Led = 16;// define LED Interface
int buttonpin = 5; // define D0 Sensor Interface
int val = 0;// define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;// define LED as output interface
pinMode (buttonpin, INPUT) ;// output interface D0 is defined sensor
}
void loop ()
{
val = digitalRead(buttonpin);// digital interface will be assigned a value of pin 5 to read val
if (val == HIGH) // When the sound detection module detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
}
- Now you have completed setting up your hardware and Arduino IDE. Copy and paste the Arduino sketch given below into your Arduino IDE and hit upload.
- After it is uploaded, the sensor will start working.
Play with the program to see how it reacts to different values and logic. This will develop your understanding about big sound sensors so you can use them in your practical application.
If you make something fun and interesting, do share it with our community! :)
That’s all for now. If you have any queries, visit surilli.io or contact our support. Stay connected with the Surilli family for more amazing stuff. :)
Comments