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.