Hi all, I am working on a project using APA104 LED strips (BIG MISTAKE

Hi all,
I am working on a project using APA104 LED strips (BIG MISTAKE for my application). I’ve integrated a bunch of patterns and special displays from code in the FastLED community. It all worked beautifully EXCEPT I couldn’t get 104s to work with DMX so I took an alternate route of using a Nano to get DMX and send it by WiFi to the Mega controlling the 104s. Reason why I said big mistake. If I researched more I would have gotten 102s and all this would be moot.
So my design/test setup was built on a breadboard using 11 trimmer pots 10K each. This allowed me to change all kinds of parameters speed/brightness/delay/direction, etc. and as I said worked REALLY well. Things just jumped around a little when I adjusted the pots with a screwdriver and settled back to solid operation when I stopped adjusting the pot.
I purchased 12 regular size pots with knobs and a case to mount the Mega and the wiring. Used the exact same wiring setup including the wires themselves. Hooked up the pots and now everything is crazy. Patterns jump, doesn’t look like pot data is getting read correctly, some pots look like their values are floating, etc.
I’ve examined the wiring using a meter, changed capacitor values, added pullup/pulldown resistors, read the pins twice in the code, just about everything I could think of. I am baffled by this! I would appreciate any ideas.
Next, I am on my sons account here and can’t figure how to get this community attached to my account. I also would like to post this code and can’t figure how to do that. Last, as I mentioned, I have been using code from other users and am a little confused about licensing. I’m not thinking of selling my system, should it ever work and I want to give credit to those whose code I’ve used.
Sorry for the length of this and I’ve been searching and trying a lot of things I’ve found here but nothing seems to work.
Thanks,
Joe B

iMac 3.06 GHz Core 2 Duo 12 G RAM
Arduino 1.64 - FastLed 3.1
APA104 LEDs - 5V 20A regulated power supply

Pastebin.com is good for sharing your code.

What is the spec of the new potentiometers? Got a link?

Sounds like the pot’s you got are cheap or cheaply made. I had to work around this once by sampling the pot 3 - 5 times and average it out. If the new sampling number was different from the previous, only then, did I assign it.

When you serial print your “settings” do you see the potentiometer numbers jumping around? Are the numbers as you’d expect?

[btw, you might want to include the pastebin link to your code here in this post so it’s in one place and other’s can more easily follow. You can edit this post and add it or just comment here and add it.]

@Jon_Burroughs
Only tried to do 2 samples. I did put delays, short 10, but that didn’t seem to help either. At one point in debugging I commented out all but the first 4 pots. When I printed the settings the unconnected ones started with a value and went up. That’s when I added pull downs.

First get your pots working. I noticed that you are reading each value 2 times w/o sampling it.
p0 = analogRead(A0);
p0 = analogRead(A0);
the second value of p0 is the only one that stays in the data register. This way you are only wasting time.

analogRead is a bottleneck; this takes around 110µs and in that time no other code can be processed.
In your case 110µs * 11 * 2 = 2420µs = 2.4ms

Smoothing the values via software is possible but you multiply the time the µC can’t process your code by the amount of samples.

I assume you tried HW-Smoothing but this does not require pullup/pulldowns as you mentioned ! You need a resistor in series and a Cap.
http://www.arduino-hacks.com/smooth-potentiometer-input/

As you are reading so many analog inputs you might have a look at this one: It reduces the analog read time 85%
////////////////////////////////////////////////////////////////////////////////////
// Sketch for Fast analogRead
// returns the time for 1000 readings

#define FASTADC 1

// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

void setup() {
int start ;
int i ;

#if FASTADC
// set prescale to 16
sbi(ADCSRA,ADPS2) ;
cbi(ADCSRA,ADPS1) ;
cbi(ADCSRA,ADPS0) ;
#endif

Serial.begin(9600) ;
Serial.print(“ADCTEST: “) ;
start = millis() ;
for (i = 0 ; i < 1000 ; i++)
analogRead(0) ;
Serial.print(millis() - start) ;
Serial.println(” msec (1000 calls)”) ;
}

void loop() {
}

// Result: 16 msec for 1000 calls = 0.016msec = 16µsec per reading
////////////////////////////////////////////////////////////////////////////////////

When you got your pot readings stable then include it in your sketch.

Btw. use for debugging a higher Serial speed than 4800 - 115200 is much better. Don’t forget to comment it out when you have your LEDs running.