Sketch not uploading changes to code unless I relaunch IDE

So I just got back into programming and started with an ardiuno. I'm having an issue where I will change an example's code, upload, but the code that gets uploaded does not reflect the changes made unless I save and relaunch. Any ideas what is/I'm doing wrong?

Are you sure that the upload is succeeding ?

Which example are you trying to upload and what have you changed ?

As an exercise, load the Blink example, change the delay() values to 200, turn on verbose reporting for compiling in your Preferences and upload the code. How fast does the built in LED blink ?

Copy the output from the compile and post it here using code tags when you do

Which board are you using and which board have you selected in the IDE ?

1 Like

Which IDE (Integrated Development Environment) are you using. The ones I use have a progress bar as it is uploading on the right just above the error screen. There are also two buttons on the top right, the left one compiles but does not upload, the right compiles and uploads.

I think it was the cheap USB hub. It stopped doing that when I plugged it in the a different source.

1 Like

If you want to make sure that the sketch program truly was written to the board, you can do this:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to Show verbose output during: compile in the "Preferences" dialog.
  3. Check the box next to Show verbose output during: ☐ upload.
  4. Check the box next to ☐ Verify code after upload.
  5. Click the "OK" button.
    The "Preferences" dialog will close.

The way this "verification" works is that, after writing the sketch program binary file to the flash memory on the microcontroller, the upload tool reads the binary from the flash memory on the microcontroller, then compares the read file against the file it wrote. If the two match, then it is certain that the binary was indeed written to the flash memory. If the two don't match then something went wrong and the verification fails.

This optional verification system is only available for certain Arduino boards, which include the AVR-based boards such as the UNO R3, Mega 2560, Leonardo, classic Nano, etc. Other boards might always perform a validation, or perhaps don't have any validation capability.

The reason the verification is not enabled by default is that the reading process does take some time and the vast majority of users would never encounter a situation where the upload is successful but the sketch program binary isn't correctly written to the flash memory (it isn't really clear under what conditions this might occur). However, in the rare case where that does occur, it can be quite confusing so some might prefer to be 100% certain whether the program truly was uploaded.

Thanks. I'll keep that in mind for the future. It was in fact a cheap usb hub only sending some code through if it hadn't been used recently.