Sound Detector
(NPN Transistor in sketch)
Connection
=== Arduino Code Sample ===
int DecPin = A5; // analog Input of Sound
int Val1; // an initial value
int Val2; // comparing value
int ValS = 5; // Sensibility
void setup() {
Serial.begin(9600);
}
int Val1; // an initial value
int Val2; // comparing value
int ValS = 5; // Sensibility
void setup() {
Serial.begin(9600);
}
void loop() {
Val1 = analogRead (DecPin);
if (abs(analogRead(DecPin) - Val1) >ValS) { // if the read value changes
Serial.println (analogRead (DecPin)); // print the value
delay(50);
}
}
Val1 = analogRead (DecPin);
if (abs(analogRead(DecPin) - Val1) >ValS) { // if the read value changes
Serial.println (analogRead (DecPin)); // print the value
delay(50);
}
}
====
Reference
Cheap Sound Sensor for AVR
http://tinkerlog.com/2007/05/20/cheap-sound-sensor-for-avr/
No comments:
Post a Comment