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

  • 1
    google arduino emulator – jsotola Nov 18 '19 at 1:50
  • Thats a reasonable option, but i still would need to upload to a board, just an emulated one, I could just use a throwaway board I have and skip the hassle of dealing with the emulator. I appreciate the suggestion though – Jordan Klaers Nov 18 '19 at 3:39
  • it is now unclear what you are asking ... you want to compile and run Arduino code without any hardware, real or virtual ... what would the program do? ... it would have no way to interact with you – jsotola Nov 18 '19 at 4:49
  • Use proteus with arduino library. – Mitu Raj Nov 18 '19 at 4:56
  • similar to using repl.it - I would like to be able to write code, that gets compiled and ran similar to what the arduino ide does. I am trying to test out different syntax for concepts I dont understand. I dont need to test working with hardware. – Jordan Klaers Nov 18 '19 at 5:35

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()
    for (;;)

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 Nov 18 '19 at 16:10
  • 1
    One could write a simple Serial class with a minimal interface that prints to stdout or the native debugger channel. – the busybee Nov 18 '19 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 Dec 8 '20 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.