Go Down

Topic: Visual Studio Code help - main sketch file? (Read 424 times) previous topic - next topic

aphelps231

I am using VSCode to write some code for my arduino and have what is probably a relatively dumb question...

How do I change the main sketch file?

As in, when you first open the program and hit the "verify" or "upload" button, it gives you a text box to select which file you want to work with. But I want to upload a different file now but am not sure how to change which one the IDE is working with.

The only way I am able to work around this without completely restarting the program is to rename the previous file to "[filename].h" or some other extension that cannot upload to an arduino board and only then it gives me the option to select the main sketch file again.

Thanks, learning a new IDE can be frustrating sometimes  >:(

GaryP

That really sounds like dumb question, maybe you don't describe your problem properly?

Write your code and save it once, then try to upload it to the board of your choice???

It is like any other text editor, so use it like one.

Cheers,
Kari
The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

noehays

#2
Aug 04, 2019, 01:01 pm Last Edit: Aug 04, 2019, 01:03 pm by noehays
I'm having the same problem as the OP. Instead verifying and uploading the sketch in the active tab (like the Arduino IDE does), the VSCode Arduino extension is operating on whatever file is referred to in a line of .vscode/arduino.json constructed as "sketch": "examples/01.Basics/Blink.ino". The only way I have found to verify or upload a different sketch is to edit or delete the arduino.json file.

I'm running VSCode on Linux Mint 19 Cinnamon 64-bit, using the Microsoft Arduino extension. Here are some of the steps of how the problem happens:

1) Delete the .vscode/arduino.json file in my Arduino workspace to start fresh
2) Open VSCode
3) Open an arduino sketch (sketch A)
4) Select board and serial port
5) Click on "verify" -- a message pops up asking me to "Select the main sketch file", with an unorganized dropdown menu of every single sketch that is in any of the workspace folders.
6) I select the filename of sketch A, designating a "main sketch file", and it verifies the sketch
7) Open another sketch (sketch B)
8 ) Click on "verify"
PROBLEM: VSCode verifies sketch A, but I want it to verify sketch B.

I can't figure out how to tell VSCode that I want to verify the sketch I am editing, rather than the one I first selected. The dropdown list does not even appear a second time.

Other than editing the json file, does anyone know how to select a different sketch?

Thanks,
Abe

Go Up