difference between serial communication and uploading sketch

Hi,
what is the difference between uploading sketch and serial communication? How Arduino knows, that data on RX, TX are to move with stepper motors and not to modify sketch? Are there some special characters before sketch to let Arduino know to modifi sketch? If yes, what will happend, if I wil send some data, which will be simillar to these characters?
Thanks.
(sorry for my english)

When uploading, a reset signal is sent through the USB cable. When the Arduino is reset, the first thing to load is the bootloader program that listens for new code being uploaded. If that doesn't arrive in the proper format within a second or so, the bootloader yields control to the most recently uploaded code.

And if there will be some power lost, which will restart Arduino and I will sending some data, is possible, that the data will be simillar to data for uploading sketch?

igendel:
When uploading, a reset signal is sent through the USB cable. When the Arduino is reset, the first thing to load is the bootloader program that listens for new code being uploaded. If that doesn't arrive in the proper format within a second or so, the bootloader yields control to the most recently uploaded code.

parmanik:
And if there will be some power lost, which will restart Arduino and I will sending some data, is possible, that the data will be simillar to data for uploading sketch?

That is extremely unlikely, it won't happen in regular use. Probably much lower chances than winning the lottery :grinning: