Disturbing Noise in Audio Signal in Connection with LED Matrix Display

Hello dear Arduino Friends,

I have the following schematic implemented using my Arduino. I want to process an audio line level signal with the described Envelope-Follower and read the output signal from the Envelope Follower by the Arduino Analog-Input. With this signal I want to control the radius of a Lissajous-figure, like shown in my code example.

The LED-matrix is working more or less like intended. But the problem that I am facing right now, that I encounter disturbing noise in the audio source signal, if I connect headphones to it.

I see this as a problem, because in the next step I want to move forward not only to have an Envelope-Follower, but also a Voltage Divider and later a FFT and a Spectrum-Analyzer.

#include "LedControl.h"

LedControl lc=LedControl(7,5,6,1);

float t = 0;
float p = 0;
float r = 0;

int iCycles;
int iPrevTime;

int iMax=0;
int iMin=1023;

unsigned long iSumTime;

int oldX = 0;
int oldY = 0;

float scale_p(int input){
  return (0.015 * (float)input + 0);
}

float scale_r(int input){
  float intern= 0.04 * (float)input + 0;
  if (intern>=3.99) intern=3.99;
  return intern;
}

void setup() {
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  Serial.begin(250000);
  r=3.99;
  p=1.5;
}

void loop() {
  
  int iA5 = analogRead(A5);

  if (iA5>iMax) iMax=iA5;
  if (iA5<iMin) iMin=iA5;

  Serial.println("iA5=" + (String)iA5 + " iMax=" + (String)iMax + " iMin=" + iMin);
      
  int x = 4 + r * sin(t*PI + p);
  int y = 4 + r * sin(t*PI);

  lc.setLed(0,x,y,true);
  lc.setLed(0,oldX,oldY,false);

 if (iCycles>=1000) {
      Serial.println("diffTime=" + (String)((float)iSumTime/1000/1000) + "ys");
      iCycles=0;
      iSumTime=0;
  }
  
  oldX = x;
  oldY = y;
  
  int iCurrTime=micros();
  int iDiffTime=iCurrTime-iPrevTime;

  iPrevTime=iCurrTime;
  iSumTime += iDiffTime;
  
  iCycles += 1;
  t += 0.01;
}

The interesting thing is, that the disturbing noise has exactly the frequency of my Arduino main loop.

My question is concerning, what kind of module or schematic I can use, to divide the LED-Matrix from the rest of the circuit, or how to divide the audio circuit from the rest of the circuit?

How can I get rid of the disturbing noises ? Are there electrical components available to solve such kind of problems?

I hope this has been clearly enough described by me.

You likely have a ground loop injecting signal directly into the audio path. Currents flowing in ground wiring
generate IR voltages, these must be prevented from getting into the audio path.

BTW that envelope-follower needs in input resistor so it doesn't short out the thing driving it on peaks, even
a few hundred ohms would probably help - that in itself could inject audio noise.

Thanks Mark!

Hello dear all, dear electronic and audio experts all around!

I added 330 Ohm and completed and optimized my electrical schematic:

I have one additional information:

Since I used only GND-Pin1 from my Arduino and connected it to the breadboard I wonder why I should have ground loops, but I am not that familiar with the science behind it.

All GND's were connected to each other at the breadboard: the PC-Audio-cable GDN, headphone GND, the Envelope-Follower GND and the LED-Matrix GND.

Now I just tried, to connect the LED-Matrix GND directly to the second GND-Pin of my Arduino and this reduced the noise significantly (as shown in the above schematic).

I don't know why this happens, but I just found it out. But the noise is still hearable.

Could someone give me an advice on how to prevent such hum loops?

Is there any component available, to put somewhere at my breadboard's circuit to get rid of such hum loops and the connected noise?

For example this one?

Thank you for your kind help!

Dear Arduino-friends,

due to a poor feedback behavior here in the forum I was solving the problem by myself.

The main topic of the solution is the Interference Suppression Capacitor (ISC) between the VCC und the GND pin of the LED-matrix as shown in my updated schematic below.

Here I present a video of the final working solution:

I hope other Arduino-friends can benefit from my solution.

Ideally you'd use a separate diode for left and right channels, otherwise you won't detect peaks reliably - for instance for tones which are in anti-phase on the two channels your circuit detects nothing. Its probably not
important for this application, but sometimes this might matter.

It also follows that naive conversion from stereo to mono is not ideal. :slight_smile:

Thank you MarkT, for your fast reply!

I will update my schematic according your advice.

Since I use a different LED matrix (Adafruit 32x16 RGB) the problem with the interference noise is gone.

This is probably because the new matrix has separated connections for power and control interface. Each separate connection has its own GND. In addition to that, I use a separate power supply.

Thank you all folks!