The matrix module is properly connected and sometimes it properly works. But most of the time, it doesn't.
And when it goes wrong during operation, the script stops working.
How can I solve this problem? Do I have to change the module?
It would be easier to find the problem if it didn't work at all, but it's not that case right now, so it's too hard.
Two suggestions, first post your code and also post an annotated schematic showing all connections, power sources, grounds and note any wire lead over 10"/25cm in length.