Can this code be smaller

The typical way to handle brightness is to use PWM pins (3, 5, 6, 9, 10, and 11 on UNO) and use analogWrite() to set their brightness through the duty cycle.

➜ Your original code was using digitalWrite so there was no brightness management.

you have more than 4 leds but assuming it was an example, you can just add an array with the PWM (brightness) values and use that instead of setting the pin HIGH

const uint8_t ledPins[] = { 9, 11, 10, 6, 3, 5 };
const uint8_t ledBrightness[] = {42, 85, 127, 170, 212, 255}; // 0 = 0FF, 255 = FULL ON (PWM)
const uint8_t pinsCnt = sizeof ledPins / sizeof * ledPins;
const uint8_t Potpin = A3;
byte currentLedIndex = 0;
unsigned long chrono = 0;

void setup() {
  for (byte i = 0; i < pinsCnt; i++) {
    pinMode(ledPins[i], OUTPUT);
    analogWrite(ledPins[i], ledBrightness[i]);
  }
}

void loop() {
  if (millis() - chrono > 500) {
    analogWrite(ledPins[currentLedIndex], ledBrightness[currentLedIndex]); // <== restore brightness
    currentLedIndex = analogRead(Potpin) > 512 ? (currentLedIndex == 0 ? pinsCnt - 1 : currentLedIndex - 1) : (currentLedIndex + 1) % pinsCnt;
    digitalWrite(ledPins[currentLedIndex], LOW);                            // <== turn off that one
    chrono = millis();
  }
}

when using PWM to control LED brightness, it is very non linear. a 50% PWM value does not make the LED 50% bright. brightness drops of very rapidly near the end of the range. for example (active LOW LEDs):

 100  255  Off
  75  254
  50  251
  25  245

presumably this suggests that the brightness increases and dims rather than just turning the LED On or Off. And this suggests that each LED is not just controlled by a single array, but at least a couple of values such as it's current brightness setting (i.e. idx to a brightness table) and whether the brightness is increasing or decreasing, direction.

presumably, instead of setting an LED On/Off, it's brightness direction is set to increasing when you want the LED On. That direction is reversed when brightness index reaches a maximum and the LED remains Off when the level reaches zero.

it's not clear if there is a sub timing interval adjusting the brightness level, that the LEDs brightness is allowed to change a little between turning the next LED On

clarifying these requirements may be more of a challenge than writing the code

hopefully it's obvious that this is a bit more complicated than just turning LEDs On/Off and reversing the direction that LEDs are turned On/Off (i.e. (! idx ? Npin-1 : --idx))

This is very obvious.

The numbers can change.
What im looking for is one on the highest brightness and the last has a very little brightness so it looks like the tail is fading

You might find it convenient to put the LED data in an array of structs so that you don't have "magic" numbers for the LED brightness scattered through your sketch. Something like this

;
struct ledData
{
    byte pinNum;
    byte brightness;
};

ledData leds[] = {
    { 3, 255 },  //pin number, brightness
    { 5, 120 },
    { 6, 80 },
    { 9, 20 }
};

byte numberOfLeds = sizeof(leds) / sizeof(leds[0]);
byte currentLed = 0;

void setup()
{
    Serial.begin(115200);
}

void loop()
{
    analogWrite(leds[currentLed].pinNum, leds[currentLed].brightness);
    delay(500);
    analogWrite(leds[currentLed].pinNum, 0);
    currentLed++;
    currentLed = currentLed % numberOfLeds;  //next LED with wrap round at zero
}

NOTES
This is an example of holding data in an array of structs. It does NOT do exactly what you want but should give you some ideas that you can apply to your sketch combined with other ideas in this topic

does this mean that the LED is turned on to full brightness and fades to Off without increasing in brightness?

does this mean that during sub-intervals, the brightness (i.e. brightness index) is decreased if > zero

Just need to edit the brightness array in my code to suit your needs

it doesn't look like the brightness is changed for a particular LED. The code just sets the same PWM value to each pin.

during each iteration, the brightness needs to be reduced for each LED and one LEDs it turned full on

I did not get that from OP’s explanation.

If that’s the case indeed my code does not match the requirements.

EDIT: indeed looking at the last explanation with the tail fading then I get what animation is expected now.

I think I will close this one because it seems that I cannot explain what I want in English.

Everyone thanks

You clearly have enough English, what you need to do is reflect upon how you would describe what you want mathematically; in English, and likely any other language, there are inexactitudes that get in the way of clarity. Mathematically, it might be sufficient to describe the brightness of each LED for three or four successive states, and explain that the series ends when all LEDs are at zero intensity. Something like:

Pass LED: 0. 1. 2. 3. 4. 5.

  1.             50. 48. 46. 44. 42. 40.
    
  2.             49. 47. 45. 43. 41. 39.
    

Etc.
Apologies for format. Phones. Sigh.

Sounds like the forum/discord throbber. All with the same pattern, but asymetric start.

Maybe you could explain your idea with raw numbers. Here I have made a spreadsheet of values for six LEDs with a step of 5 and change direction near 0 and 255.

255	213	170	128	85	43
250	208	165	123	80	38
245	203	160	118	75	33
240	198	155	113	70	28
235	193	150	108	65	23
230	188	145	103	60	18
225	183	140	98	55	13
220	178	135	93	50	8
215	173	130	88	45	3
210	168	125	83	40	8
205	163	120	78	35	13
200	158	115	73	30	18
195	153	110	68	25	23
190	148	105	63	20	28
185	143	100	58	15	33
180	138	95	53	10	38
175	133	90	48	5	43
170	128	85	43	0	48
165	123	80	38	5	53
160	118	75	33	10	58
155	113	70	28	15	63
150	108	65	23	20	68
145	103	60	18	25	73
140	98	55	13	30	78
135	93	50	8	35	83
130	88	45	3	40	88
125	83	40	8	45	93
120	78	35	13	50	98
115	73	30	18	55	103
110	68	25	23	60	108
105	63	20	28	65	113
100	58	15	33	70	118
95	53	10	38	75	123
90	48	5	43	80	128
85	43	0	48	85	133
80	38	5	53	90	138
75	33	10	58	95	143
70	28	15	63	100	148
65	23	20	68	105	153
60	18	25	73	110	158
55	13	30	78	115	163
50	8	35	83	120	168
45	3	40	88	125	173
40	8	45	93	130	178
35	13	50	98	135	183
30	18	55	103	140	188
25	23	60	108	145	193
20	28	65	113	150	198
15	33	70	118	155	203
10	38	75	123	160	208
5	43	80	128	165	213
0	48	85	133	170	218
5	53	90	138	175	223
10	58	95	143	180	218
15	63	100	148	185	213
20	68	105	153	190	208
25	73	110	158	195	203
30	78	115	163	200	208
35	83	120	168	205	213
40	88	125	173	210	208
45	93	130	178	215	203
50	98	135	183	220	198
55	103	140	188	225	193
60	108	145	193	230	188
65	113	150	198	235	183
70	118	155	203	240	178
75	123	160	208	245	173
80	128	165	213	250	168
85	133	170	218	255	163
90	138	175	223	250	158
95	143	180	228	245	153
100	148	185	233	240	148
105	153	190	238	235	143
110	158	195	243	230	138
115	163	200	248	225	133
120	168	205	253	220	128
125	173	210	248	215	123
130	178	215	243	210	118
135	183	220	238	205	113
140	188	225	233	200	108
145	193	230	228	195	103
150	198	235	223	190	98
155	203	240	218	185	93
160	208	245	213	180	88
165	213	250	208	175	83
170	218	255	203	170	78
175	223	250	198	165	73
180	228	245	193	160	68
185	233	240	188	155	63
190	238	235	183	150	58
195	243	230	178	145	53
200	248	225	173	140	48
205	253	220	168	135	43
210	248	215	163	130	38
215	243	210	158	125	33
220	238	205	153	120	28
225	233	200	148	115	23
230	228	195	143	110	18
235	223	190	138	105	13
240	218	185	133	100	8
245	213	180	128	95	3
250	208	175	123	90	8
255	203	170	118	85	13

And here is the graph of the data showing each LED PWM decreasing to zero then increasing. You can even see where I made some changes to the values.


Maybe you can make a spreadsheet, or a chart, or draw a picture of your LED lighting idea?

Here is that data in an array of PWM values...
int ledval[] = {
  255, 213, 170, 128, 85, 43,
  250, 208, 165, 123, 80, 38,
  245, 203, 160, 118, 75, 33,
  240, 198, 155, 113, 70, 28,
  235, 193, 150, 108, 65, 23,
  230, 188, 145, 103, 60, 18,
  225, 183, 140, 98, 55, 13,
  220, 178, 135, 93, 50, 8,
  215, 173, 130, 88, 45, 3,
  210, 168, 125, 83, 40, 8,
  205, 163, 120, 78, 35, 13,
  200, 158, 115, 73, 30, 18,
  195, 153, 110, 68, 25, 23,
  190, 148, 105, 63, 20, 28,
  185, 143, 100, 58, 15, 33,
  180, 138, 95, 53, 10, 38,
  175, 133, 90, 48, 5, 43,
  170, 128, 85, 43, 0, 48,
  165, 123, 80, 38, 5, 53,
  160, 118, 75, 33, 10, 58,
  155, 113, 70, 28, 15, 63,
  150, 108, 65, 23, 20, 68,
  145, 103, 60, 18, 25, 73,
  140, 98, 55, 13, 30, 78,
  135, 93, 50, 8, 35, 83,
  130, 88, 45, 3, 40, 88,
  125, 83, 40, 8, 45, 93,
  120, 78, 35, 13, 50, 98,
  115, 73, 30, 18, 55, 103,
  110, 68, 25, 23, 60, 108,
  105, 63, 20, 28, 65, 113,
  100, 58, 15, 33, 70, 118,
  95, 53, 10, 38, 75, 123,
  90, 48, 5, 43, 80, 128,
  85, 43, 0, 48, 85, 133,
  80, 38, 5, 53, 90, 138,
  75, 33, 10, 58, 95, 143,
  70, 28, 15, 63, 100, 148,
  65, 23, 20, 68, 105, 153,
  60, 18, 25, 73, 110, 158,
  55, 13, 30, 78, 115, 163,
  50, 8, 35, 83, 120, 168,
  45, 3, 40, 88, 125, 173,
  40, 8, 45, 93, 130, 178,
  35, 13, 50, 98, 135, 183,
  30, 18, 55, 103, 140, 188,
  25, 23, 60, 108, 145, 193,
  20, 28, 65, 113, 150, 198,
  15, 33, 70, 118, 155, 203,
  10, 38, 75, 123, 160, 208,
  5, 43, 80, 128, 165, 213,
  0, 48, 85, 133, 170, 218,
  5, 53, 90, 138, 175, 223,
  10, 58, 95, 143, 180, 218,
  15, 63, 100, 148, 185, 213,
  20, 68, 105, 153, 190, 208,
  25, 73, 110, 158, 195, 203,
  30, 78, 115, 163, 200, 208,
  35, 83, 120, 168, 205, 213,
  40, 88, 125, 173, 210, 208,
  45, 93, 130, 178, 215, 203,
  50, 98, 135, 183, 220, 198,
  55, 103, 140, 188, 225, 193,
  60, 108, 145, 193, 230, 188,
  65, 113, 150, 198, 235, 183,
  70, 118, 155, 203, 240, 178,
  75, 123, 160, 208, 245, 173,
  80, 128, 165, 213, 250, 168,
  85, 133, 170, 218, 255, 163,
  90, 138, 175, 223, 250, 158,
  95, 143, 180, 228, 245, 153,
  100, 148, 185, 233, 240, 148,
  105, 153, 190, 238, 235, 143,
  110, 158, 195, 243, 230, 138,
  115, 163, 200, 248, 225, 133,
  120, 168, 205, 253, 220, 128,
  125, 173, 210, 248, 215, 123,
  130, 178, 215, 243, 210, 118,
  135, 183, 220, 238, 205, 113,
  140, 188, 225, 233, 200, 108,
  145, 193, 230, 228, 195, 103,
  150, 198, 235, 223, 190, 98,
  155, 203, 240, 218, 185, 93,
  160, 208, 245, 213, 180, 88,
  165, 213, 250, 208, 175, 83,
  170, 218, 255, 203, 170, 78,
  175, 223, 250, 198, 165, 73,
  180, 228, 245, 193, 160, 68,
  185, 233, 240, 188, 155, 63,
  190, 238, 235, 183, 150, 58,
  195, 243, 230, 178, 145, 53,
  200, 248, 225, 173, 140, 48,
  205, 253, 220, 168, 135, 43,
  210, 248, 215, 163, 130, 38,
  215, 243, 210, 158, 125, 33,
  220, 238, 205, 153, 120, 28,
  225, 233, 200, 148, 115, 23,
  230, 228, 195, 143, 110, 18,
  235, 223, 190, 138, 105, 13,
  240, 218, 185, 133, 100, 8,
  245, 213, 180, 128, 95, 3,
  250, 208, 175, 123, 90, 8,
  255, 203, 170, 118, 85, 13
};
Code to read and display that data on LEDs on the PWM pins...
// pwmThrobber

#include "database.h"
int led[] = {3, 5, 6, 9, 10, 11}; // LED PWM pins
int leds = sizeof(led) / sizeof(led[0]); // LED count
int rows = ((sizeof(ledval) / sizeof(ledval[0])) / leds); // rows in database

void setup() {
  Serial.begin(115200);
  for (int i = 0; i < leds; i++)
    pinMode(led[i], OUTPUT);
}

void loop() {
  for (int i = 0; i < rows; i++) { // rows in database
    for (int j = 0; j < leds; j++) { // LED PWM pin array
      analogWrite(led[j], ledval[i + j]); // write to the PWM pin, the row value
    }
    delay(100); // slow the effect
  }
}

Come on !
You can do it !

The first LED comes on a full brightness. What happens next ?

Does the first LED dim to nothing then turn off and we move on to the second LED ?
or
Does the first LED turn off and the second one come on at reduced brightness and so on down the row of LEDs ?
or
Something else ?

Way to make it obscure (via ternary operators) and slow (via modulus)...

How about something like:

   int increment;
   int pot = analogRead(Potpin);
   digitalWrite(ledPins[currentLed], LOW);  // reset
   if (pot > 512) {    // same as "increment = pot > 512 ? 1 : -1;"
     increment = 1;   // count up
   } else {
     increment = -1;  // or down
   }
   Serial.print(F("Aan: "));
   Serial.println(currentLed);
   Serial.print(F("Uit: "));
   Serial.println(ledPins[0]);
   digitalWrite(ledPins[currentLed], HIGH);
   currentLed += increment;     // increment or decrement
   if (currentLed >= sizeof(ledPins))  { // check for overflow/underflow;
     currentLed = 0;            // back to 0
//   or reverse direction?
//   currentLed = sizeof(ledPins) - 1;
//   increment = -increment;  // back up 1.
   } else if (currentLed < 0) {
     currentLed = sizeof(ledPins) - 1;   //  back to end
//   or reverse direction?
//   currentLed = 0;
//   increment = -increment;
   }
   delay(500);

Mind

This test will fail

for small divisors that are constants and especially powers of two, GCC AVR optimizes modulo using compare and clear too. So with a constant like 6, my bet would be that it won’t actually do a division; it’ll generate essentially the same code as increment and compare.

Otherwise you are right it can cost may be about 2 microseconds more, likely invisible in this use case.

Easy enough to check.
Apparently not...

void loop() {
  if (millis() - chrono > 500) {
    digitalWrite(ledPins[currentLedIndex], HIGH);
    currentLedIndex = analogRead(Potpin) < 512 ? (currentLedIndex == 0 ? pinsCnt - 1 : currentLedIndex - 1) : (currentLedIndex + 1) % pinsCnt;
 3c6:   90 e0           ldi     r25, 0x00       ; 0
 3c8:   01 96           adiw    r24, 0x01       ; 1
 3ca:   b8 01           movw    r22, r16
 3cc:   0e 94 eb 01     call    0x3d6   ; 0x3d6 <__divmodhi4>
 3d0:   d7 cf           rjmp    .-82            ; 0x380 <main+0x15e>
 3d2:   85 e0           ldi     r24, 0x05       ; 5
 3d4:   d5 cf           rjmp    .-86            ; 0x380 <main+0x15e>

I would have been very impressed if the compiler analyzed the code sufficiently to know that the range of the dividend was small enough that it only needed a compare...

I won't argue with that. But it also somewhat hides what is happening...

Thanks for checking out. I remember having seen it but may be I got confused.