Hi All,

I'm looking for help on the best way to structure code that has multiple tasks happening, while not interrupting or slowing the overall operation at any given time.
For example, i want to drive 16 LEDs using a 4x4 (Multiplexed) matrix (4 rows x 4 columns)
The LEDs in the matrix will be often changing states and/or flashing in various patterns.

The LED status and flash speeds will be dependent on settings of various pots and switches wired to the PIC.
The LED patterns vary from switching approx 10-20 times per second down to say once per second, while other LEDs are just static ON or off.
Of course the 'ON' LEDs need to look like they're stable, not flickering due to the speed of the matrix scanning being interrupted by the code going to process a pot-change etc.

In my past attempts (long ago), while my projects have worked overall, i suffer too much interruption to the LEDs while adjusting pots and setting external switches to alternate values.
So, in all, i need to master how i use loops to monitor/switch everything cleanly. Are there preferred ways to do this?
My loops in the past have always revolved around goto's & gosubs, i've never ventured into using DO loops or WAITs, WENDs etc...maybe this is what i'm lacking?

I haven't provided code for my example, as this is just an open question about general structure and loop techniques (rules of thumb) that people use for speed efficiency.
Before you ask, it's now slow hardware or slow chips, it's *me* not structuring my looping and I/O monitoring correctly.

Any suggestions are greatly welcomed, i can only learn what i've been doing wrong all these years lol ;-)

Regards,
Marty.