A better way to import Arduino projects into VSC (Visual Studio Code) and PlatformIO .

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in my last video i showed you how to install the platform io extension into visual studio code platform io sits on top of vsc and that's the menus that we need to use so to import a sketch from an arduino such as blink which we're going to do if you have a look around you've got file and it'll say new file and so forth open all the rest we don't bother about that there's also the explorer view on the side we don't bother with that we go straight to the alien which is platform io and then we go to open and after a short while we'll get a menu you've got the options of a new project or importing an existing one from arduino this is very restrictive but i'm going to show you the import button anyway and i'll show you the disadvantages of it so we press that button and it asks us what we want to import now i've got a usb stick a green one and the code is on there and it's blink so then you press import and you find you've got an error because it's not really intuitive up here we have to select a board so i'm going to select on uno board and then before i go to import i just want to make you aware of this it says well there's nowhere there really to tell you what file name it's going to use for the end project and if i want to save the project back onto the usb stick i haven't really got a choice for that at all it's actually in this folder projects which on my machine is c users slash richard slash onedrive slash document slash platform io slash project and then within its own directory structure so it's not that easy to find and it's not where we want it but we'll go ahead with that anyway so i'm going to import so there it is imported and you can see it's been given a name on the top left it's been given the name with the date and the time and oh no and we've got platform any file which will close and we can close that one so the source code is in src and that's the blink code that we've got and you can see it's showing up errors now they're not errors it will compile all right but down at the bottom right it says because it's not a c plus plus file and we've got to convert it it it won't recognize ino files so one way is to actually just rename that cpp and of course it doesn't make any difference at all so we've got three problems there we've got the first thing is the intellisense doesn't recognize it the next one is we can't name the file ourselves and the third one we can't put it where we want it to be so what i'm going to do is show you the manual way which is a lot better so we close that right click on there to close that one remove that from and then just close that one so we'll start again and do it the manual way so alien open we're going to create a new file a new project which will be empty apart from the arduino structure of loop and setup so i'm going to new project i'm going to call it 2021 503 because that's the date and i'm going to call it link and i'm going to select a board which is a lot more obvious this time and look it says location just here so if we untick that we go down we say we want it back on our stick if we have a quick look on the stick we have just one file if i can just get a bit closer to that that's all that's on that stick it's just that one folder and that one file so i'll go back to there so i'll just save it which i seem to put the button down at the bottom where you can't see it so i click on finish it will then prepare that sketch and present it on the left let's wait for the dot ina i file to be created and then you know you're done so we get rid of that one and we close that one so look at the source now it's main cpp and we've just got a blank framework what we do now is we go into explorer we're going to notepad find the original sketch copy it paste it back into the editing area note we have to include the arduino.h header on line one as you can see there's no errors and if we go down to the bottom left a little tick we can compile it and it will compile perfectly so the intellisense works we have the file where we want it and it's called exactly what we wanted if we have another looking explorer if i can find it on my machine then that is the the what what's now on that usb stick and if you notice it's the same as this and the um the explorer view here so it's basically a copy so this explorer just is basically an explorer it doesn't show all the things the programs thing so if we double click on source we can see we've got the main cpp and when it was made so that's all for this time next time i'll show you how to import whole projects it's a lot easier than this very similar and a lot quicker and it's a lot safer for version control as well
Info
Channel: Richard Langner
Views: 704
Rating: undefined out of 5
Keywords: Visual, Stdio, Code, Arduino, PatformIO, 101, tutorial, basic, extensions, add-ons, VSC, starting, beginner, Uno, esp8266, sonoff, esp32
Id: f2bUPz47dc8
Channel Id: undefined
Length: 6min 19sec (379 seconds)
Published: Mon May 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.