Can anybody tell me why this function dies out after about 20 minutes?

Can anybody tell me why this function dies out after about 20 minutes? It works fine, and then will freeze and turn off.

https://pastebin.com/dg2uAwu2

Hi @John_D , idex is probably overflowing to a negative number, which is returning a negative number when you use it in the modulus operation. Try making idex an unsigned integer?

Further to that, I’d be making everything unsigned.

@Chris_Parton Thank you! That did the trick!

@John_D No problem, glad I could help :slight_smile: