Dimming 60 led aray

This is a project i'm working on and it is functional, The dimming is a bit jerky....not smooth, is there a work around to this also is there any suggestions to improving this project....Regards.

xrayxray:
The dimming is a bit jerky....not smooth, is there a work around to this

Try removing the delay() and all the Serial.print() functions (which are also delays).

One (other) solution is to collect a sample set and average it out. So instead of reading the POT and changing the LEDs output right away, read in 10 or 20 values, calculate an average and then output it to the array (if the value is different from the previous one.) Something like:

int numReadings = 20;
int dimmer = 0;
int readings[numReadings];
int index, total, average = 0;
int prevval = 0;
long lastRun;

void setup() {
  // reset array for good measure
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}

void loop() {
  if (millis() - lastRun > 10) {
    total = total - readings[index];
    readings[index] = analogRead(dimmer);
    total = total + readings[index];
    index++;
    if (index >= numReadings) index = 0;

    average = total / numReadings;
    // Only change if the value is smaller or larger than 4 points difference
    // Honestly, the human eye can't tell a 4-point difference ...
    if ((average < (prevval - 4)) || (average > (prevval + 4))) {
      out = map(average, 0, 1023, 0, 255);
      // Do something with 'out'
      prevval = average;
    }
  lastRun = millis();
  }
}

That will give you a fairly smooth transition. If you don't like the 4-point difference, change it, or remove it altogether. It just means you're updating the array more often, especially if your POT isn't very accurate and jumps by itself.

Thanks for the suggestions, I dropped the Delay and seriel print and it's a definate improvement.....thanks.
I tried copy and paste of the code Posted by: KirAsh4 and the code wouldn't compile...maybe I'm missing something with my understanding of code writing as this is all new to me.
Once again thanks.

xrayxray:
I tried copy and paste of the code Posted by: KirAsh4 and the code wouldn't compile...maybe I'm missing something with my understanding of code writing as this is all new to me.

That doesn't help. That's like saying your computer won't turn on. My obvious question would be: did you plug it in? Or did you push the power button?

My point is, you need to give us a little bit more details, such as what's the error message you are getting? What does the code look like? ALL of it.

Yes it's plugged in and button pushed.
, here is a snip of the Verify page.

First: post your code inside of CODE tags. Copy and paste it, then highlight it again and click on the # in the icons above your post. Don't post screen grabs because that won't show the whole thing.

Second: my bad, change the following:int numReadings = 20;
to a constant instead:const int numReadings = 20;

And define out as well:int out = 0;