I want to use only *.cpp files and no *.ino anymore. I read a lot of stuff about how to upload c++ instead of arduino sketches. But still I was not able to find a step by step guide how to do it.

Actually I am developing my sketch within Spacemacs (Emacs) and uploading it with Arduino-Makefile (https://github.com/sudar/Arduino-Makefile)

When I now want to start a new project with only *.cpp and *.h files to use classes etc. how would I start? Does anybody has the time to describe a rough step-by-step without the trivial stuff?

  • .ino files are C++ files. You could just rename your main C++ file with the .ino extension and compile it with the IDE or Sudar's Makefile. If you are not using the Arduino core library, a much simpler Makefile could do it. – Edgar Bonet Sep 23 '16 at 20:42
  • yea but what about these loop() and setup() functions. I know I could write a main() function instead but well...there must be some kind of conventional interface so the microcontroller knows what to start running. Or are those two "arduino" functions wrapped by a main() function which just calls setup once and calls loop() in a while-loop? – xetra11 Sep 23 '16 at 20:59
  • 1
    If you're moving to a standalone project then why do you care what the Arduino libraries do? If you need the Arduino libraries then why are you moving to a standalone project? – Ignacio Vazquez-Abrams Sep 23 '16 at 22:00
  • I never said I want to skip the arduino library. Still want to use it but not in a ino file – xetra11 Sep 24 '16 at 6:54

See my post about How the IDE organizes things.

Also see my page about how to avoid the quirks of the IDE sketch file pre-preprocessing.

You can certainly manage without .ino files. As Edgar Bonet says, they are really C++ files with certain pre-processing (see link above).

but what about these loop() and setup() functions

Effectively, the Arduino IDE supplies a main function that looks like this:

int main ()
  init ();    // initialize hardware, including timers and timer interrupts
  setup ();   // user setup
  while (true)
    loop ();  // stuff to be done repeatedly
  return 0;   // this will never be executed

(It's slightly more complex, to allow for USB where applicable, but that is the idea).

But still I did not found the step by step guide how to do it.

I'm pretty sure there are a lot of example "make" files around which show the idea.

I have an example here.

| improve this answer | |

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.