Since the signal of the microphone is too little to drive directly the analog input, we need to amplify it. Furthermore a good read of the analog input can be done if the input signal is between 0 and 5V so we also need to offset it. This can be done through an operational amplifier. In particular we will use an inverting amplifier because is simple and an audio signal is not affected by a rotation of 180°.
2. SchematicThis is the resulting schematic.
Now we can simply read the analog input in this way. Take note that if there isn't an audio signal the read will be about 512 because to have an audio signal between 0 and 5V we need an offset of 2.5V. Little variations are caused by the noise.
/*Read the analog input of a microphone
Author: Arturo Guadalupi */
int micIN= A0;
int audioVal = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
audioVal = analogRead(micIN);
Serial.println(audioVal);
delay(600);
}
Comments
Please log in or sign up to comment.