I know very well that the code is working, but when it comes to uploading it, it is not possible for me since it throws me the following error that you will show below.
Arduino:1.8.19 (Windows 10), Board:"Arduino Nano, ATmega328P"
Sketch uses 5194 bytes (16%) of program storage space. The maximum is 30720 bytes.
Global variables use 288 bytes (14%) of dynamic memory, leaving 1760 bytes for local variables. The maximum is 2048 bytes.
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
An error occurred while sending the sketch
This report could contain more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.