1

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?

4
  • .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. Commented Sep 23, 2016 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? Commented Sep 23, 2016 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? Commented Sep 23, 2016 at 22:00
  • I never said I want to skip the arduino library. Still want to use it but not in a ino file Commented Sep 24, 2016 at 6:54

1 Answer 1

4

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.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.