Reputation: 51
Long-time Arduino IDE user, one-day VS Code + Arduino extension user:
When I first load a sketch and do "Arduino:Initialize", the name of the sketch is stored in the arduino.json settings file, e.g. "sketch": "esp32_test/esp32_test.ino". It then compiles ok when I press the "Verify" button.
But if I close that sketch and open a different one, and then do "Arduino:Initialize", the first file is NOT replaced in the arduino.json file. The first one remains there. I get a message that says, "Arduinio.json is already generated." So when I try to compile the new file, the old one is compiled instead.
The only way I've been able to compile a different file is to manually edit the arduino.json settings file to remove the "sketch": "esp32_test/esp32_test.ino" entry. Then AND ONLY THEN will the .json file update to allow me to compile the new file.
Shouldn't this happen automatically when I select/edit a file and hit the Verify button? Maybe there's an issue with my installation...?
(forgot to mention: VS Code + Arduino on OSX 10.14.6)
Upvotes: 5
Views: 6676
Reputation: 1
If the arduino.json file in the .vscode directory is not set up correctly, the target sketch will not appear at the lower panel. Correct syntax of the file will imply that the target sketch is displayed at the lower panel. Otherwice the file name is not shown. Clicking on the target skecth file name will cause the list of alternative target sketches will be listed at the top of the VIsual Code window. From this list, you can choose another target sketch to be compiled.
Upvotes: 0
Reputation: 39
I know exactly the issue you are having - because it happens to me quite often.
In the status bar, often the sketch file name will not be displayed for some reason - I think this is an issue with the Arduino extension. You'll see everything else you need - board, port, etc, but not the "target sketch"
Here is how you can change the "target sketch":
Like other respondents mentioned, it "should" be shown in the task bar, but for some reason it does not sometimes.
Upvotes: 3
Reputation: 99
It's no intuitive.
You should select the sketch in the status bar:
and then you can change the sketch in the upper screen text box:
Upvotes: 0
Reputation: 51
Down at the bottom, on the right you'll see the Arduino status bar. There you'll find your board, your programmer, your port... and the .ino file that you're compiling. Click there, change the name to the sketch you want to compile and done!
Upvotes: 5