Ok I think I might know how to do it but not too sure.
The great thing about software, unlike just about any physical technology, is that it is relatively easy, at this level, to build as many prototypes as you need to get it right.
Read the blink without delay example and really understand what it is doing.
Simplify the problem whilst you are working the technique, like one range/relay - after that, it should be relatively simple to expand.
Post your code AND your results if you get stuck.