My problem is that the laser can be turned on, but it can't be turned off. Sometimes it succeeds in ten attempts. I tried TFT display or serial control but still the same problem. Am I doing anything wrong? or is the hardware so busy that it can no longer accept further ID? Mega 2560, wemos mega wifi r3 atmega2560 esp8266.
What is sending the serial commands to the Arduino ?
We haven't seen the rest of your sketch, so who knows what it is doing when the laser is turned on ? Please post a complete sketch that illustrates the problem
Personally I have never seen the point the the SerialEvent functions. You might just as well use the available() function in loop() and do something if serial data arrives. I would also use strings rather than Strings, but that is another debate