So I'm working for a project to control RGB Led Strip using microphone or sound sensor with
Arduino Nano. I'm using
5050 RGB Led Strip around 120 LEDs, and I control them using simple transistor circuit to each channel R, G, and B, then I connect the base of the transistors to the resistors and PWM Outputs of the Arduino. And then I'm using
KY-038 Sound Sensor (I'm using the Analog Output pin) and connect it to Arduino
The problem is when I didn't connect the LEDs, the microphone worked correctly. I processed the analog input, put filter and threshold. When I connected the LEDs, the reading of the
A0 is disturbed by the transition of the LED (for example from 0% PWM to 50% PWM or ON). As the result, my analog read detected it as a voltage swing and recognize it as a sound, and trigger the LEDs, then oscillating without any external sound. If I disconnected the LEDs, it worked correctly, for example I change it to Arduino Built-In LED, it turned on according to the external sound.
Why does this happen? I don't think they share the same timer, and I also use proper Power Supply and Capacitor to provide the enough power.
My project is similar to this project.