My project is to use the Makeblock Ultimate 2.0 robot kit to create a balancing robot that is controlled wirelessly by a Nintendo Wii nunchuck starting from the firmware. The 3,000 lines of code is so complicated and involved that it is hard to understand. I have progressed to the point that I have what I think of as a vibration(timing) problem. So, I am ready to move on from the Arduino IDE to something that can give me more information and help. So, I installed Visual Studio Code and the Arduino extension. But with Blink I cannot get past a "Serial.print" error. Literature says that the PlatformIO extensionis better than the Arduino extension. So, I installed it and am following the instructions in the User guide.

Before I was studying the Arduino extension without success. I have left it and the

Serial.print();

command behind.

Now I am working on and with the PlatformIO extension for four days. For four days I have not gotten a response by other methods. This forum seems to be different. Your instantaneous response surprised me.

Yes, I have gotten a notice that the Arduino extension and the PlatformIO extension clash at Intellisense. So, the Arduino extension is disabled. I compose my posts in word. Sometimes the copy past has unexpected results. And your forum editor is new for me. Also, PlatformIO does not run the Arduino INO files. An

#include <Arduino.h>

must be inserted. What I cannot explain is why the dependencies for Arduino.h are not found.

I would like to "Rebuild Intellisense index" but I cannot find the command.

working… so what is the controller for that? It looks to be a custom version of the Arduino Mega board…

MegaPi is small but powerful mainboard based on Arduino MEGA 2560.

So to get started, you should only need the board definition for the Arduino Mega 2560 in your platformio.ini, not the dozen or so different board environments you have configured!! I looked at the boards search page, put mega 2560 into the search and had at look at the documentation for that specific board. Based on the info on that page, replacing what you currently have in your platformsio.ini file with the following …

… will give you just one build environment, called megaPi, configured for the mega2560 board time, to be programmed using the arduino framework.

Then, since platformIO can be used to program many different board types, and with more than just the arduino programming language, we #include <Arduino.h> so that the special Arduino stuff is included.

A simple blink sketch such as the following should then build fine, but you may have to configure your upload port for it to upload properly. We’ll deal with that problem if you encounter it.

Yes. This robot board is mainly a motor controller. You might call it a custom board. Although each/all boards can be called custom. It seems to pretend/program as if it is a standard/clone Arduino Mega 2560 as follows . . .

● Microcontroller: ATMEGA2560-16AU

● Input Voltage: DC 6V-12V

● Operating Voltage: DC 5V

● I/O Pins: 43

● Serial Ports: 3

● I2C Interface: 1

● SPI Interface: 1

● Analog Input Pins: 15

● DC Current per I/O Pin: 20mA

● Flash Memory: 256KB

● SRAM: 8KB

● EEPROM: 4KB

● Clock Speed: 16 MHz

● Dimension: 85*63mm

That is the board that I choose/chose. Although that may have been the Arduino extension. I have gone back into Visual Studio Code and the PlatformIO extension to find that the commands are mostly at the bottom of the screen.

Although I doubt that I should have to manually type the PlatformIO.ini file.

Let me go back to the beginning. I am trying to move on from the Arduino IDE. While in Visual Studio Code, a PROGRAM.ino file listing has SERIAL underlined with a red squiggle. I get the message . . .

"C/C++ IntelliSense service does not support .INO files. It might lead to the spurious problems with code completion, linting, and debugging. Please convert .INO sketch into the valid .CPP file."

And indeed, if I run such a program, it does in fact run fine.

To accomplish the conversion, I can and have save/d from Visual Studio Code into a CPP format. But then when I go back to the finder to look at the file it shows as still being an INO file. I can change the name of the file. I can save into a CPP format.

Arduino format is so much like CPP format that there is room for confusion. So, I resaved WiiAccessory.ino as a Closure document and then resaved again as a CPP document. I now have an original INO file in three(3) formats(INO, Closure and CPP). I do not anymore get the error message . . .

“C/C++ IntelliSense service does not support .INO files. It might lead to the spurious problems with code completion, linting, and debugging. Please convert .INO sketch into the valid .CPP file.”

Note that in WiiAccessory.cpp(originally .ino) has “Serial” underlined with a red squiggle and does not seem to work correctly. “Blink.cpp” (imported as .cpp) has “#include <Arduino.h>” underlined with a green squiggle and runs fine.

Within the workspace, you have four project folders - WiiAccessory, Me_(2CScanTest, 190312-092555-megaatmega2560, and 190312-02626-arduino-blink. 190312-02626-arduino-blink is the only valid one for bulding with platformio as it is the only one with a correct folder structure and platformio.ini file.

With regard to

Although I doubt that I should have to manually type the PlatformIO.ini file.

… this is indeed the case if you have already created a project, or wish to add another board type to an existing project. This is part of the whole reason the PlatformIO.ini file exists. If you were instead to use the ‘New Project’ option on the PIO Home screen, you would be able to simply give the project a name and choose your board from the list, and PIO would generate the platformio.ini entries for you. But again, as soon as you want to change that, or add more boards, you would have to edit the platformio.ini file.

Arduino format is so much like CPP format that there is room for confusion.

Yes, they are very similar, as the Arduino ‘language’ is based on the C++ standard, with helper functions, and some wrapper code that means you don’t need declare functions before using them. However, the actual file format is the same - they are plain text files. The only thing you needed to do was change the file extension from .ino to .cpp - i.e. right click on it in the file explorer, and choose rename.

First. You cannot know that. My posted list was manually typed in with shortcuts. While I can find a command to "Collapse all" folders, I do not see a command to open all folders. And the list with all folders open would be quite long. For this learning process, I am focusing on just two(2) programs.

The workspace has four project folders
WiiAccessory
Me_I2CScanTest
190312-092555-megaatmega2560
190312-02626-arduino-blink

WiiAccessory folder (WiiAccessory.ino) is from the Arduino IDE and includes .vscode (arduino.json, c_cpp_properties.json), WiiAccessory.ino. It does not seem to be fully developed as it does not include a lot of Platform information. In spite of this I have been complaining that the Intellisense was not working properly. No more. It is deleted.

Me_I2CScanTest folder (Me_I2CSanTest.ino) is from the Arduino IDE and includes .vscode (arduino.json, c_cpp_properties.json), Me_I2CSanTest.ino. It does not seem to be fully developed as it does not include a lot of Platform information. I have put it behind me. It is deleted.

190312-092555-megaatmega2560 (Blink.ini) Does seem to be a fully developed PlatformIO project but is in .ini form. Deleted.

190312-02626-arduino-blink (Blink.cpp) this leaves the workspace with only one project (folder): 190312-02626-arduino-blink.

I have used my new knowledge to push forward back to my project. It is a running program in the Arduino IDE. When I first imported it into PlatformIO it had 66 errors. Now with new knowledge, I have started over and have only 3 errors.

I have unfound dependencies. They are on the hard drive although they are deep in the folders. I thought that “c_cpp_properties.json” would find them. It did not. I have tried to put a path to the unfound libraries into “c_cpp_properties.json – browse” only to have them overwritten. For eeprom, there are two versions in three locations. Arduino has a 9KB version and makeblock has a 26KB version. PlatformIO uses the 9KB version.

My earlier response was based on the information given, nothing more, nothing less. I didn’t realise you had omitted some of the information. However, if the platformio.ino file is missing, it is not a platformio compatible project, and platformio will not work.

Mark:

This seems like a direct quote. But I cannot find that text in the FAQ.

er… it’s from the message you see when you try to add / open an arduino sketch containing a .ino file?

As far as the included libraries, you may have some trouble if the mBlock folks have modified the stock standard Arduino libraries for their own purposes. You may be able to use the lib_extra_dirs option in platformio.ini to configure C:\Program Files (x86)\mBlock\Arduino\hardware\tools\ as a path, but I don’t know if that is the best option there. But these were just warnings weren’t they, not actual compile errors that stopped the firmware being built? Warnings like that are normal, and in fact the Arduino IDE is actually configured to hide most of them by default, so that you won’t see them.

Ok, after a little more looking, you should be using the MakeBlockDrive library developed by MakeBlock for their devices and as you can clearly see from the the list of includes there, they are including a custom EEPROM library, called MeEEPROM, etc. etc.

Get that library installed (add lib_deps = MakeBlockDrive to your platformio.ini file) and try copying the firmware_for_megaPi into your blink.cpp file. But before you try to build it, you will need to declare the function prototypes otherwise you will get build errors. Basically, I just put in at around line 251 (just before the first of the functions was implemented) the following block, and that will make the compiler happy when it’s trying to link everything together. Note that there may be a scollbar on the side of the list because there are a lot of functions!

Then when you build the code, PlatformIO will automatically download the MakeBlockDrive library since you’ve indicated the project has a dependency on it, and it should compile fine. You will see a bunch of ‘problems’ listed, but the code will compile.

First, in looking at eeprom I also noticed that there is an EEPROM. Also, some mornings I seem to get farther after the computer has been shutdown and restarted. Perhaps there is a reset button that I am unaware of. You mention the difference between warnings and errors. With Blink.cpp, I was getting supposed errors but took the seemingly bold effort to compile anyway. And Blink.cpp did in fact compile and run and is running now. So, they were in fact warnings and not compiler errors. I have moved on from Blink.cpp!

The firmware you refer to seems to be for a generic Makeblock board and is quite old. Makeblock has firmware for different purposes and versions all over the place. It is difficult to find the latest appropriate version.

Makeblock at GitHub lists five(5) versions of firmware. Presumably this is for five distinct boards. Although this concept puts into question robots and kits not listed. mBlock is their programing app. I have the Ultimate 2.0 kit. It is not their Starter kit. I do not know and have never heard of a “Pro”. Auriga? So, I use “Firmware_for_MegaPi” (Firmware_for_MegaPi.ino).

Vincent He 2019/01/04 3.2.6 1.Mbot /ranger adds the function of communication variables. 2.Solve the blocking problem of 9g steering gear. 3.Solve the problem that the intelligent steering gear cannot read back the parameters. 4.Add version number function. 5.High power code motor reinforcement version query function. 6.Solve the problem of SetColor (uint8_t index, long value) function error in mergharp.cpp. 7.The mBot board cannot extinguish the RGB. First upload the program with the RGB in any color, and then upload the program with the RGB in all colors. The RGB cannot extinguish (MeRGBLed bled. CPP file). 8.In the MegaPi firmware, SLOT1 is changed to slot_num instead of parameter transmission in the command processing stepper motor.

The Readme of 0e.01.016 calls it both 3.2.6 and 3.26! The most resent firmware for the Ultimate 2.0 seems to be 3.26(3.2.6)(0e.01.016)! Thus (0e.01.016), (3.2.6), (3.26), and (Firmware_for_MegaPi.ino) are all the same thing. My robot program is a copy/paste of the Makeblock firmware 3.2.6!

I am now back to my robot program. It lists at about 3100 lines. Realize that my Makeblock robot program builds on top of the Makeblock firmware software. I mean that my robot program IS the Makeblock firmware(3.2.6). The first 3000 lines of my robot program IS the Makeblock firmware. My original contribution of code amounts to about 100 lines.

The 52 functions that you list are the ones in Firmware_for_MegaPi.ino(3.2.6)! I know them well. I work with them every day. Makeblock uses this software to communicate with an Ipad or phone (Ios or Android) by Bluetooth(Serial2). My project is to replace the Ipad or phone with a wireless Nintendo Wii nunchuck.

Just make sure the aforementioned list of function prototypes is placed before that first function declaration. If you wanted, there is nothing to stop you putting it in right under all the #includes in the first few lines of the file… it simply needs to be located before any of the functions are actually declared.

The Arduino IDE does not require the functions to be pre-stated. It seams that C++ does. You have chosen after variable definition and before the first function. (line 251). I have literally chosen the line before the first function. (line 267). It amounts to about the same thing. But I am using an edited version of "Firmware_for_MegaPi.ino" 3.2.6! I am not sure that you are. Thank you.

That post was long enough. It was time for a break.

I may have a new issue. I have encountered Visual Studio extension conflicts(messages). So, some have been uninstalled and other installed. There may be a magic combination that works best. In my current install (as shone) most of the PlatformIO icons at the bottom of the screen do not show.

This implies that the decleration of the function was found, but its implementation was not provided or not compiled in. In which CPP files to they implement this function? Was this file also placed in the src/ folder?

"Conflicted extensions with IntelliSense service were detected (Arduino). Code completion, linting and navigation will not work properly. Please disable or uninstall them (Menu > View > Extensions)."

The extensions have the buttons Enable, Disable, Uninstall, Reload Required. After pressing one, sometimes I get the message . . .

Please reload Visual Studio Code to complete the disabling of this extension.

And it never shows up on a print screen.

Anyway, the PlatformIO buttons are back.

Exactly, that’s why it complies with INO extension but not with CPP extension.

I under appreciated the Arduino IDE’s efforts. I have read the FAQ. Thanks for the extra info.

This is a conversion problem from INO to CPP.

Respectfully, again, my robot program is 99% the "firmware_for_Mega.ino". I do not need to link to the firmware because my program is the firmware. At least it worked that way with Arduino. All of the Makeblock code is in the file. The Nintendo code must be imported. I have put my robot program into DropBox. But I may have to take it back. Windows 7 did a MOVE and not a COPY. Following is the link I was given to my robot program. Realize that this code was not polished for distribution. It is a demonstration of a beginners learning process.

As I look at the file names in the error messages, I realize that these are the individual files in the Makeblock library. Perhaps I am not properly connected to that library. My platformio.ini is as follows . . .

It’s also interesting to note that there is another pull request from December where someone has gone to the trouble of fixing some (but not all) of the warning’s that come up when compiling… but it hasn’t been accepted yet, so I wouldn’t hold my breath on a quick response…