You need to merge the 2 codes into a single code which achieves whatever pattern of LEDs you need.
It's hard for anyone to help with more detail because you have not made it clear how you want to make the led patterns. How many 8x8 panels will your project use? How will the pattern of LEDs look as the pot and distance sensor values change? Your attempt to explain that is very ambiguous.