Could i use all this code as a secondary code
But the main program not to be affected by this code.
?

using that code it takes about 1mS to send data to 24 ws2812's . so if your main program can tolerate 1mS gaps in processing every 50mS it would work ok

if you used a more modern chip with a clc module then you could adapt my code
found here :-
http://www.picbasic.co.uk/forum/atta...5&d=1508279203
that updates the leds as a background interrupt driven process with very very little overhead

see this thread for that and other more efficient possibilities
http://www.picbasic.co.uk/forum/showthread.php?t=23399

But i really dont know how to import all this code or how to use this DT's interrupt method here.
what have you tried ?