Saturday, December 13, 2014

Editing Arduino sketches with IntelliJ Idea 13.1 and C++ plugin

I started building Arduino backed robot per instructions in http://blog.miguelgrinberg.com/post/building-an-arduino-robot-part-ii-programming-the-arduino and quickly discovered pain of editing the sketches in Arduino IDE. The pain forced me to release C++ plugin 0.8.6 for IntelliJ Idea 13.1, new version is functionally identical to previous version except supports newer version of IntelliJ Idea.

To edit sketches one needs to specify extra include paths from Arduino Ide installation (e.g. %arduinoidepath%/Resources/Java/hardware/arduino/cores/arduino , %arduinoidepath%/Resources/Java/libraries/SoftwareSerial) and add "ino" extension mapped to c/c++ file type. Another needed configuration setting for resolving Arduino built-in symbols (like Serial) is specifying custom file in Additionally automatically included header file of C/C++ project settings. The file (e.g. ArduinoSetup.h) should have following content for auto adding Arduino specific symbols declarations in every file:

#define UBRRH
#include "Platform.h" // Arduino symbols declarations

Once one finishes with sketch editing one can use Arduino IDE to upload the sketch to the device.

2 comments:

Némésis said...

Hello,

I'm very interested in using Intellij to build Arduino programs, their IDE makes me crazy.

Could you please write a tutorial or instructions on how to set-up Intellij with your C/C++ plugin ?

How can we select the destination COM port and upload to the Arduino ?

Thanks for you work !

GreenCheddar said...

hello I just created a Github account just so I could follow your progress on this plugin for Android Studio. I spent the last 2 days trying to setup android studio so I can write an activity completely using native code. Now that I have figured it out, your plugin is the only thing I have been searching for. Finally my code has custom colors lol. Thank you so much for this utility. May the cyber gods smile upon you.