Recently I have started developing for Arduino Uno. I have 10 years experience in software development (C#, Delphi), but not much with C/C++. Compiling the Arduino sketches seems a little slow, and debugging isn't as convenient as it could be on a PC (compile, upload, watch the serial monitor, modify code, start over.... way too slow with lots of unnecessary steps) So what I would like to achieve is to organize my code in a way to be able to compile my code either to Arduino, or to PC for debugging purposes (to a small console app). I know that there are libraries that cannot be used on a PC, but those can be abstracted away (hidden behind a facade or something like that). Unfortunately I could not find any tutorials, or articles how to do this. So I hope you can help me out.

BTW I'm using Visual Studio (with Visual Micro) on a Windows 10 computer.

  • How you plan to replicate things like buttons, led, sensors and relays?
    – user31481
    Commented Dec 16, 2017 at 15:49
  • With abstractions as I said. Of couse those stuff won't work on a PC but for example a led can be replaced with a Console.WriteLine. Sensors are providing data in a form of bytes/bytearrays, which can be faked with abstractions. With fakes the logic can be built/validated on PC much more faster than with a real board.
    – morcibacsi
    Commented Dec 16, 2017 at 15:57
  • What you're looking for is an Arduino Simulator. I seem to recall people doing it Proteus, but don't quote me on that. It's something like that anyway.
    – Majenko
    Commented Dec 16, 2017 at 16:26
  • This may help: instructables.com/id/How-to-Simulate-Arduino-in-Proteus
    – Majenko
    Commented Dec 16, 2017 at 16:27

1 Answer 1


I haven't done it yet, but you could do the following things to get a somewhat close approximation:

  • Make three different projects, one for the PC (only), e.g. Visual Studio, and one for Arduino (with the default Arduino IDE or e.g. Visual Micro). The last will be a generic library to be used for both the PC and Arduino.
  • Use the Arduino specific libraries only for the Arduino project.
  • Create facade/wrapper classes for each Arduino library.
  • Use a mock/stub for the Arduino libraries in the PC only project.
  • Put all non-hardware related code in separate classes, to be used by both projects.
  • Write unit tests for the PC only project.
  • The PC project will be tested by unit tests, and can be debugged on a PC
  • Only the specific Arduino libraries/interfaces have to be tested using the 'hard way', e.g. with Serial.

So the projects (including testing) will look like:

  • PC Project
    • References common code
    • Stubs for Arduino libraries, stubs can possibly be reused by PC Unit tests
  • PC Unit Tests
    • Unit tests
    • References common code
  • Arduino Project
    • Containing Arduino libraries
    • References common code
  • Common Code
    • All domain specific classes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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