proximity sensor + electret microphone = no compatible??

Hey guys,

I am having a trouble when I connect and infrared proximity sensor ( and an preamplified electret microphone (
When I connect the sensors separately, they work perfect, but when I connect both together the electret microphone reads signal of 1023 (5V) at all time.

Do I have to get the voltage from different power sources? That would be very weird.


Here I leave you the electret mic sketch to read the signal if its necessary.

const int micPin = A2;   
int valueMic = 0;
int valueMicMax = 512;
int valueMicMin = 512;

void setup() {

void loop() {
  for (int i =0; i < 100; i++){
    valueMic = analogRead(micPin);
    if (valueMic > valueMicMax){
      valueMicMax = valueMic;
    } else {
     if (valueMic < valueMicMin){
      valueMicMin = valueMic;
  valueMic = valueMicMax-valueMicMin;
  valueMicMax = 512;
  valueMicMin = 512;

How are you wiring them up exactly? Your code doesn't mention the proximity sensor.

They’ve been wired normally. 3 pins for each component. Voltage,ground and analog in. proximity sensor is in A1 and microphone in A2
The code is just for the electret microphone as I said before. Because the problem appears when I wire the proximity sensor at the same voltage line of the microphone.


Possibility: The Infrared sensor uses relatively high powered pulses at 38 KHz. Maybe that signal is getting into the microphone preamplifier. Try temporarily putting a capacitor across the microphone terminals.. maybe .1 uF or so. It will hurt the high frequency audio response, but if it makes a big different you are on the right track..

I would also add a larger capacitor (10 uF or so) right at the voltage supply terminals of the microphone.

If you had an oscilloscope or access to one you could trace what signal is getting in to the Mike / amplifier.