Arduino with Sound Sensor and LED
Hello everyone! Today I will show you how to use a sound sensor with arduino.
The required kits are :
- An arduino and its adapter
- Few jumper Wires
- A digital Sound sensor
- A led
- AO-Analog pin
- G-Ground pin
- +-positive power pin
- DO-digital output pin
The steps to setup hardware are listed below:
- Connect "+" pin to 5V pin on the arduino.
- Connect "G" ground pin to GND pin on the arduino.
- Connect "DO" digital output pin to any analog or digital pins on the arduino.In this tutorial I connected it with A2
- Connect longer LED leg to pin 13 on the arduino. If you want to use anyother pin on the arduino, you need to use a 220 ohm resistor.
- Connect shorter LED leg to GND pin on the arduino.
The setup is complete. Now, upload the code and enjoy.
Remember to adjust the potentiometer. Doing so will solve your led continuosly blinking problem.
Check out the tutorial here:
const int ledpin=13; // ledpin and soundpin are not changed throughout the process
const int soundpin=A2;
const int threshold=200; // sets threshold value for sound sensor
void setup() {
Serial.begin(9600);
pinMode(ledpin,OUTPUT);
pinMode(soundpin,INPUT);
}
void loop() {
int soundsens=analogRead(soundpin); // reads analog data from sound sensor
if (soundsens>=threshold) {
digitalWrite(ledpin,HIGH); //turns led on
delay(1000);
}
else{
digitalWrite(ledpin,LOW);
}
}
Nice
ReplyDeletec:\program files\arduino\hardware\tools\avr\bin\../lib/gcc/avr/7.3.0/../../../../avr/bin/ar.exe: unable to rename 'core\core.a'; reason: Permission denied
Deleteexit status 1
Error compiling for board Arduino Uno
c:\program files\arduino\hardware\tools\avr\bin\../lib/gcc/avr/7.3.0/../../../../avr/bin/ar.exe: unable to rename 'core\core.a'; reason: Permission denied
Deleteexit status 1
Error compiling for board Arduino Uno
c:\program files\arduino\hardware\tools\avr\bin\../lib/gcc/avr/7.3.0/../../../../avr/bin/ar.exe: unable to rename 'core\core.a'; reason: Permission denied
Deleteexit status 1
Error compiling for board Arduino Uno
In which language we have to type this code..
ReplyDeleteWill it work on c++ emulator
USE C
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHyperx quadcast or samson g track pro? hyperx quadcast usb condenser gaming microphone
ReplyDeletewhat is meant by setting the threshold value? I do we have to adjust the potentiometer?
ReplyDeleteWhat code should be written if i want to drive another pins along with pin 13, means i want my output on pin 13 also
ReplyDeleteSorry last pin no was pin 12 not 13
ReplyDeleteCzy można dodać kolejne diody i jak?
ReplyDeletec:\program files\arduino\hardware\tools\avr\bin\../lib/gcc/avr/7.3.0/../../../../avr/bin/ar.exe: unable to rename 'core\core.a'; reason: Permission denied
ReplyDeleteexit status 1
Error compiling for board Arduino Uno
any solution for this
Hi do you do customized projects?
ReplyDeletei need it so when there is no sound it goes of not when there is sound how would i chang the code
ReplyDelete