To explain my project very quickly, I've made a line of lamps (halogen), which would visualize the amount of sound, more lamps going on if the sound is loud.
I'm using this microphone: MAX9812.
The setup works really well if it's just the arduino running. The relay/code reacts nicely to the amount of sound coming in. (More relay gates opening if the sound is loud, and closing when it's quiet again). However, when I put power on the relay and lamps the sound doesn't reset, but instead uses the highest number it got as a base. For example, if there was only background noise the signal would be around 300, blow into the mic or tap on it and it would go up to 500 and when I stop it goes back to 300. When the power is on it doesn't go back to 300.
It doesn't reset if I reset the code, or reupload it. The only way I have found to reset this, is to remove all power from both the arduino and the relay, leave it for a while and then come back.
The analog output of the microphone goes directly into (tried with different resistors and and doesn't make a difference) the Arduino A0 port.
Can anyone help me with this? I don't think it's the code and instead the lamps messing with the signal?
Let me know if you need the code and/or setup, and sorry if my explanation isn't clear.
How I solved it, probably a stupid way but it worked. I got another arduino uno which only houses the microphone, and uses serial communication to send the received value to the other arduino.