Serial.write() blocks receive when written inside draw() function

Hi @mohitSingh, Interesting project, nice looking GUI. As you say there’s more there than anyone can immediately analyse.

For following the sequence of what happens I suggest you print out everything that is sent and received, and your program states. Run it for a few moments After a few moments run, copy the console window to an editor, and study what happened.

Are you using a real com port? that is always there on the PC? or a software created one, like the Arduino drivers create? If the software type, are you disconnecting the board with the sketch still running? Then reconnecting it or another. If the order of actions is wrong the port won’t work until you fix it. Let me know and I’ll give more details if relevant.

(You really should convert some of your code to use arrays. This would eliminate lots of lines, and make small adjustments to e.g. size and spacing of objects much easier.)