Since I tend to spend a lot of time in Visual Studio Code for other projects these days, I spent a little time moving my Arduboy projects from Arduino to VSCode this morning, and thought I’d write up the process.
First, set up Platform.IO. It installs as an extension to VSCode. Details on basic installation are at A professional collaborative platform for embedded development · PlatformIO, so follow that to get it installed on your system.
If you want to move an existing Arduino-based project over, go to the PlatformIO home screen (with the home icon installed at the bottom of the VSCode window), and choose “Import Arduino Project”. You’ll eventually get to navigate to find the folder where your .ino file is, and it will create a new project folder, and copy over everything.
After that copy, you’ll need to rename your new .ino file to have a .cpp extension instead. You probably should move your header files from the src folder into the parallel include folder. You’ll also need to add the Arduboy libraries you are using. I found that the “use libraries from your Arduino” folder option didn’t work well for me. However, all of the libraries that I’d used from Arduino were also available via PlatformIO. To search for these, bring up the library UI by going to the Platform IO home, then clicking on the Library tab. You can search for libraries like “Arduboy2”, “ArduboyTones”, or “FixedPoints”, and use the “add to project” button to get them added to your platformio.ini file.
This platformio.ini file is the key to understand how the build works. For my projects, it ends up looking like
[env:arduboy]
platform = atmelavr
board = arduboy
framework = arduino
lib_deps =
mlxxxp/ArduboyTones@^1.0.3
pharap/FixedPoints@^1.1.0
mlxxxp/Arduboy2@^6.0.0
The lib_deps list is saying that I need those libraries at that version number or later. The build ending will automatically pull down the code and include it in the project. The platform line specifies that we’re using the AVR toolchain, while board says we’re building for Arduboy, and framework enables the Arduino API support, including the automatic invocation of the setup() and loop() functions.
I found that after adding the libraries, I still had a little build problem with my code being unable to find the Arduboy2.h header, but it was solved by closing the IDE and reopening it.
For the most part, the toolbar buttons (which also map to commands you can invoke) work like the Arduino IDE. Check will build, but not upload it to the target. Upload does a build first, then invokes an upload tool. You get the build output all shown in a terminal pane and can easily step through problems.
For making a new project, you can either create it with the Platform IO dialog wizard, or just copy the folder to a new location and use VSCode’s Open Folder to open it. The PlatformIO extenstion will see the platformio.ini file and enable it. Since I do a lot of different project types, I turned on the setting to only run the PlatformIO extension when that file was in the workspace directory.
If you want to see how I setup my projects, I added the setup as a new branch in my GitHub repos.
- GitHub - unwiredben/arduboy-ravine-despoiler at main-platformio
- GitHub - unwiredben/arduboy-beamemup at main-platformio
I ended up doing more manual migration for the BeamEmUp repo which made it look like a more natural branch from main, where with Ravine, I just force push the branch which removed the connection. I may end up trying to fix up the Ravine branch to have proper history when I get a change.