A Nano drives a 24xLED Ring and uses an analog input to read a mic.
When I switch all LEDs on I see the analogread drop to around 50 and stays there for around 100ms and then moves back to 512. When I turn them off analogread rises to 1023 and stays there for the same amount of time. Attached is also a plot of the data: blue=‘nullAudio’, orange=‘variation’, and gray box=‘color’ ( on/off period )
use external power supply for the ring. at least 2A.
I suppose power goes down when LEDs goes on, USB2.0 support up to 500mA.
UPD. Are you sure LED diagram synchronized with Mic gain diagram?
UPD2 on mic module are 2 coils on GND and VCC. On you breadbord is no 1000µF capacitor to see. so i can suppose generated distortion are very high and mic modules coils suppress them to very small voltage.
External PSU will helps.
I will have to add the resistor and cap to my breadboard and see what effect it has on the analogread - but the readings without them are decoupled the LED power now.
The only issue is that I want to use only one 5V power source. Any idea how that can work?
So you now realise that as the Adafruit module (for which sadly they do not provide a schematic ) is not powered by a bipolar supply and presumably has no output capacitor, the additional components are unnecessary.
Good trick. I may not have tried too hard but Adafruit was not giving it away easily for that module. Did you have to go to Github (which I understand has been debased )? Perhaps post it here.
There's always going to be some noise because your room isn't perfectly quiet and there is always some electrical noise and you have a high-gain preamp that amplifies any noise along with the signal.
"Real" professional microphone preamps have balanced-differential inputs to minimize hum from the mic & cable and the preamp circuit often has it's own-separate voltage regulator or power supply or some filtering to minimize power supply noise. And of course they use a low-noise op-amp, and put it in a metal/shielded case.
And, raw audio data "looks like" noise because you are randomly(1) sampling a constantly-varying waveform. Even the "data' from a pure sine wave will look random.
But you should be able to see the difference between loud and quiet sounds.
With louder sounds some readings will deviate more from zero (or more from the bias) but there are still lots of values between the positive & negative peaks. With quiet sounds all of the readings will be near zero (or near the bias if you haven't subtracted-out the bias).
(1) It's not really "random" but the sample points are not correlated with the waveform so you might sample a positive or negative peak (or near a peak) or you might sample a zero-crossing (or a near zero-crossing)
Try it on just the microphone board, or maybe on the microphone board & Arduino, or you can try two of these, one for the Arduino and one for the microphone board.
The LEDs should connect directly to the power supply, bypassing the filter(s).
There is a voltage drop across the diode so with a 5V supply you won't get the full 5V out. A Schottky is preferable because it has a 0.2 or 0.3V drop whereas a regular silicon diode has a about a 0.5 - 0.7V drop. But if you have a regular diode you can try it, and if helps you can optionally "upgrade" later. And in general, the bigger the capacitor the better.
I call this a "half-filter" (I don't know if it has a name). "Negative" noise-spiles on the power supply (where the voltage drops-down) are filtered-out. The capacitor holds-up the voltage on the output side of the filter, and the diode prevents the capacitor from discharging into the power supply or LEDs. The capacitor only has to power the preamp or Arduino temporarily until the power comes-back to normal.
It doesn't help much more than a capacitor alone with positive spikes, but it does help a little because the positive-spike has a negative-going edge, and that is discharged slowly and "smoothed out".
The half-filter can work great if you're powering the Arduino and powering through Vin with more than 5V while using the built-in voltage regulator. The voltage regulator is a very-good noise filter by itself and the capacitor in the half-filter protects against negative glitches or shirt voltage dropouts.
The application is just with USB power so I don't think the diode will work but I'll give it a try.
To give the project it's use-case: The mic is there to pickup the sound and I'll do something audio reactive. The current design works good if it's loud but the more quiet it gets the more the noise and 'feedback' from the LEDs making it hard to control.
I am wondering if I can calculate the current draw from the LEDs into the supply voltage and offset the result of the ADC accordingly. in FastLED there is this calculation :
//// POWER MANAGEMENT
// These power usage values are approximate, and your exact readings
// will be slightly (10%?) different from these.
//
// They were arrived at by actually measuing the power draw of a number
// of different LED strips, and a bunch of closed-loop-feedback testing
// to make sure that if we USE these values, we stay at or under
// the target power consumption.
// Actual power consumption is much, much more complicated and has
// to include things like voltage drop, etc., etc.
// However, this is good enough for most cases, and almost certainly better
// than no power management at all.
//
// You're welcome to adjust these values as needed; there may eventually be an API
// for changing these on the fly, but it saves codespace and RAM to have them
// be compile-time constants.
static const uint8_t gRed_mW = 16 * 5; // 16mA @ 5v = 80mW
static const uint8_t gGreen_mW = 11 * 5; // 11mA @ 5v = 55mW
static const uint8_t gBlue_mW = 15 * 5; // 15mA @ 5v = 75mW
static const uint8_t gDark_mW = 1 * 5; // 1mA @ 5v = 5mW
Since I know the pixel values I can predict the current and possibly the voltage drop. The unknown part is the characteristic of the mic module and why it's taking the time (about 100ms) to adapt to the new voltage. Unfortunately I have no scopes to measure if the voltage actually stays lower if the LEDs are 'on' or if the mic module has some slow reacting filter.