with this amplify circuit (was recommended at this forum)-
and i also connected the output of the amplifier (the transistor collector) to pin 0 through 0.1uF capacitor. the empty thing in the middle is where the PNP transistor goes in
i'm using this code:
int led = 8;
void setup(){
pinMode(0,INPUT);
pinMode(led,OUTPUT);
Serial.begin(9600);
}
void loop(){
 digitalWrite(led,LOW);
int micvalue= analogRead(0);
Serial.println(micvalue);
delay(200);
if(micvalue>650){
digitalWrite(led,HIGH);
delay(30);
}
else{
digitalWrite(led,LOW);
}
}
in silence i get somthing like 630-640~ and when i put my iphone next to the mic, the micvalue goes above 650 - it stays above it get stuck at 740 or 900 or any value bigger than 650, and then the led blinks without stopping.
here is a video of it:
Where did you get that mic circuit? Its nonsense. You have 3.3V rail shorting out the signal.
As usual wikipedia wins for us:
But actually the capacitor isn't needed as we can do the low-pass filtering in software
after the ADC, so just a single resistor is enough.
BUT that's unlikely to work - microphones output a signal level of a millivolt or so at
normal sound levels. You won't be able to see that directly with the ATmega's 10 bit
ADC unless you shout right into the microphone.
Connect a 10K or so resistor from A0 to ground. Experiment with the value.
terryking228 - it did work, i'm getting 0-2~ in silence and it goes up dependes on the noise. BUT im having another problem:
i hooked up the led to a PNP transistor and changed the code a bit:
int led = 8;
void setup(){
pinMode(0,INPUT);
pinMode(led,OUTPUT);
Serial.begin(9600);
}
void loop(){
digitalWrite(led,HIGH);
int micvalue= analogRead(0);
Serial.println(micvalue);
delay(50);
if(micvalue>25){
digitalWrite(led,LOW);
}
else{ digitalWrite(led,HIGH);}
}
so now the led turn on only when there is sound. TWO THINGS:
my main goal is to activate/fire a dslr flash. so it's look like this
im connecting the two wires (blue&white) to emitter&collector, and when i make sounds nothing happens. i tried changing the sides of the wires (blue to collector and white to emitter) but no change, and when i connect the led it's works. if i connect directly the blue wire to the white the flash fires of course.
when only the led connected, when there is sound the led blinks in very low light (dimmed). i thought maybe it's because it's happen very quickly so i delayed the blink for 10ms , and then the micvalue is stuck again on 300 and somthing.....
are you sure its not going to damage my flash or Arduino connecting the 5v to the emittet together with the flash?
And what about the collector leg? Gnd?
and I know there is a better microphone with an amplifyer but right now I have this one and I prefer to use it. But thanx for the offer
You seem to be confusing yourself (& us) by attempting to debug everything at once. I suggest you get the input working (just use Serial.print () to show what you are reading, then get the LED behaving the way you want (maybe Serial.parseInt () to provide fake levels), and then get your logic worked out (again using Serial to supply levels and monitor program flow).
Or any other order that suits you. Divide & conquer.
Right now the only problem i have is that theflash doesnt fire - and terryking228 explained why- the PNP to the camera is just "floating. And he advised me with a solution butmy worry is:
are you sure its not going to damage my flash or Arduino connecting the 5v to the emittet together with the flash?
And what about the collector leg? Gnd?
And i dont have an optoisolator right now, so i just wanna make sure his solution not gonna harm my flash