
Thursday, September 25, 2008
Problem
The mic works fine with the code till the led is added- when the led is added the mic stops functioning properly.
Code
code taken from: http://forum.sparkfun.com/viewtopic.php?t=11430&highlight=sound
modified with Anders's help
int audioIn = 0;
int val = 0;
int ledPin1 = 2;
void setup() {
pinMode(ledPin1, OUTPUT);
Serial.begin(9600);
}
void loop() {
val = analogRead(audioIn);
Serial.println(val);
if (val <=600){
digitalWrite(ledPin1, HIGH);
}
else{
digitalWrite(ledPin1, LOW);
}
}
modified with Anders's help
int audioIn = 0;
int val = 0;
int ledPin1 = 2;
void setup() {
pinMode(ledPin1, OUTPUT);
Serial.begin(9600);
}
void loop() {
val = analogRead(audioIn);
Serial.println(val);
if (val <=600){
digitalWrite(ledPin1, HIGH);
}
else{
digitalWrite(ledPin1, LOW);
}
}
datasheet of electret microphone
Taken from the Spark Fun Electronics website:
http://focus.ti.com/lit/ds/symlink/opa344.pdf
http://focus.ti.com/lit/ds/symlink/opa344.pdf
Project Description
Where does the product live?
This product is on the side of a busy road.
What does it do?
It reflects the noise level on the road and stops people from honking aimlessly. Drivers can see the product and judge the decibel levels produced by them collectively.
How does it work?
Sound captured by a mic acts as an input and lights up the led within the product (output). The sound is proportional to the number of lights that shine- the higher the sound, the more the lights shine.
(the form and the material of the product is still being thought of)
This product is on the side of a busy road.
What does it do?
It reflects the noise level on the road and stops people from honking aimlessly. Drivers can see the product and judge the decibel levels produced by them collectively.
How does it work?
Sound captured by a mic acts as an input and lights up the led within the product (output). The sound is proportional to the number of lights that shine- the higher the sound, the more the lights shine.
(the form and the material of the product is still being thought of)