I am not super experienced with c++ and I know that the syntax for C++ and the code written/compiled by the arduino IDE are slightly different.
I would like to be able to write code, compile it the same way the arduino IDE does, and run it, without uploading it to a board.
I dont need to test any code that interacts with any hardware. I simply want to be able to test basic syntax to make sure my concepts work before integrating with the full program.
I have written a few Arduino programs and I think the most complicated thing I've used were pointer functions, but I'd like to be able to test out code without needing to upload to a board for every change, while relying on Serial.print.
I have found alternatives that help with debugging and although that is helpful, I'd like to avoid the need to upload to a board every time I want to test changes for basic concepts
2 Answers 2
You can use any C++ IDE you like, best when bundled with a compiler, for example Code::Blocks. Assuming you're using Windows: A combination of a decent editor like Notepad++ and some good compiler chain like MinGW will do, too. If you absolutely have to you could also use MS Visual Studio, I don't bother.
Then create standard console programs with this main()
:
void setup();
void loop();
int main()
{
setup();
for (;;)
{
loop();
}
}
And append your hardware-less Arduino code.
-
Need to get rid of Serial.print at least :) :-) But alas, with a debugger, you don't need that Serial.print at all.DataFiddler– DataFiddler2019年11月18日 16:10:53 +00:00Commented Nov 18, 2019 at 16:10
-
1One could write a simple
Serial
class with a minimal interface that prints tostdout
or the native debugger channel.the busybee– the busybee2019年11月18日 17:01:52 +00:00Commented Nov 18, 2019 at 17:01
PlatformIO is a plugin for Visual Studio Code that has support for many embedded device, including most Arduinos
-
The principle question seems to be about testing their code, in some capacity, without having to upload to an Arduino on each test. It would probably help to say how PlatformIO enables this.timemage– timemage2020年12月08日 13:17:40 +00:00Commented Dec 8, 2020 at 13:17
arduino emulator