Using "debug" in "Arduino Pro micro" will make the program run abnormally

Hello everyone, I am using “Arduino Pro micro” for programming. I use “platform IO” to debug my “Arduino Pro micro”. I find that the program will not run normally



At the moment, my pin 9 is connected to “GND”.
If I don’t use “platform IO” for debugging, this program can run normally


What’s the platformio.ini?

From the program code it doesn’t look like you’re using avr-stub to debug a real device, but rather the default simavr. This is a simulation program and will not access your real hardware. If you want to debug on real hardware you must not use the Serial and add debugging per this.