Description: Really simple and inexpensive sound sensor.
Specifications: This is a sound sensor that is really great in certain applications. If you need to sense sound from silence to a loud noise, it works really well. Not recommended as a musical beat catcher, although if you hit the super-sweet spot on the trimpot on board, you may think you have something. Connect to the power an GND on your Arduino, and hook to an analog input.
You can use this code here to get started:
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for milliseconds:
delay(sensorValue);
}
|