Nano freezes after several loops

I’d start by commenting this out, assuming you are using a classic Nano. Then, if necessary comment out say all the sensor statements to see if the screen works. Continue until you localize the cause.