The remainder will always be between (including) zero and one less than NUM_LEDS, so will be pointing within the array

that's not always true

You have this:

`#define NUM_LEDS 200`

--> Mind negative values when doing modulo operations and be careful with the implicit type of a `#define`

(a signed int)

You need to make sure the total count used for the modulo is a `uint16_t`

. Test this for example:

```
int value = -5;
#define totalCountSigned 200 // will be seen as a signed integer
const uint16_t totalCountUnsigned = 200; // an operation involving an unsigned larger than a byte will get promoted to unsigned calculation if the size is large enough (16 bits will do)
void setup() {
Serial.begin(115200);
Serial.print("Signed modulo : "); Serial.println(value % totalCountSigned);
Serial.print("Unsigned modulo : "); Serial.println(value % totalCountUnsigned);
}
void loop() {}
```

Serial Monitor (@ 115200 bauds) will show

Signed modulo : -5

Unsigned modulo : 131

so as you can see, using a #define for the count is not a good idea as you get a signed computation and modulo does not know how to deal with this.

if you use an `uint16_t`

, the -5 gets promoted to its unsigned representation so (65536-5) and then the modulo is applied, that's why you get 131.

This might not be what you expected though. So my advice would be to handle the circular buffer "manually" by testing with an if clause the calculated index and finding the right matching position if that index is negative / beyond bounds.