user16647: Please, help me to set up Clion + Arduino. 
Clion has an Arduino plugin which I've installed. Here is some instruction on Github but I'm fully noob about cmake and other things which are talking about in instruction. I have only used Arduino IDE before for my simple projects. Now in CLion I can create an Arduino projects but autocompletion doesn't work. Actually it works but does it on true C, not for Arduino code. 
So if you can please explain like for complete idiot, what I should change to get working Arduino autocompletion. 

user19671: I know this was asked a long time ago, but maybe it will be useful for someone. I'm a beginner, regarding all this stuff, so if anybody knows a better way to do it, please correct me. here is how I set up CLion for Arduino (on Windows 10):
CLion 2016.1.3 + Arduino 1.6.9 + plugin

Download and install the official Arduino IDE (1.6.9).
Download and install MinGW to 'C:\MinGW'
In MinGW, install: 'mingw32-base' and 'mingw32-gcc-g++'
Download and install CLion.
Create an 'untitled' project, just to open CLion.
In CLion > Settings > Plugins > Browse Repositories > Search for and install: 'Arduino' (tools integration), and 'Serial Monitor' (misc).
In CLion > Settings > Search > type 'MinGW'
At the environment select 'Use MinGW home', and browse to MinGW folder ('C:\MinGW'). Press apply, and wait until CLion finds the environment.
In File > Close project.
Open any file manager and go to 'c:\Users\name\ClionProjects\' and delete the 'untitled' project you just created.
Open CLion, select 'New Arduino sketch project'
In the project directory > 'open cmakelists.txt' and configure lines:
6: set board version
7: set port (you can find out port# from the Arduino IDE)
8: set the path where you installed your Arduino libraries (Arduino sketch folder)

set(${CMAKE_PROJECT_NAME}_BOARD uno)
set(${CMAKE_PROJECT_NAME}_PORT COM3)
LINK_DIRECTORIES(c:\\ARDUINO\\libraries)

In the upper right corner in CLion, near the green 'Play' button, select 'Edit Configuration', on the left select 'Application' > 'Upload', and set:
-target: 'upload'
-configuration: 'debug'
-executable: the project name

then press ok.
In the project .ino file, write some really simple code (blink).
Connect an Arduino Uno via USB, and press the green 'play' button to upload the sketch.
To start serial monitor:

In CLion main window bottom left, click serial monitor tab (in 'the tool buttons')
Click the wrench icon to set up port and baud rate.
On the top of the wrench icon, click the blue 'connect' icon.
If values did not appear 'correctly', click the white 'switch to hex' icon (on the right of the wrench).
Before uploading sketch, disconnect the serial monitor.

For CLion to properly find the libraries, make sure to use the same name for the lib folder as for the '.h' file. example: for DallasTemperature.h use folder name DallasTemperature. After #inlcude-ing new libs, right click on 'External libraries folder' and select 'Reload cmake project'.
You may want to do further configuration in CLion settings like: theme, colours, text size, etc.
Also, you can configure some handy 'live templates', like: serialprintln, digitalwrite, pinmode, switch, etc. to enhance your productivity.


user16852: Rather than using any plugin, I am using CLion with PlatformIO, which supports several IDEs. CLion then not only gives you code completion, but also full support for refactoring, Git, and much much more.
From its documentation:

[...] generate project via platformio init --ide command:
platformio init --ide clion --board %TYPE%

# For example, generate project for Arduino UNO
platformio init --ide clion --board uno


Then import the project in CLion and you're about done.
Some hints:

Make sure your code is in the src folder, and that the main file has a .cpp extension.

For other files: either rename all .ino files to use .cpp, or tell CLion to associate the .ino extension with C++ files. (Preferences, Editors, File Types.)

Whenever adding libraries to the lib folder (and using #include to refer to them), just run the above init command again.

If you're using ESP-boards and changed platform.txt for an alternative esptool, then note that PlatformIO needs a different hack.

Rather than using the CLion Serial Monitor plugin, I simply use a Terminal within CLion to upload and start the monitor as soon as possible:
pio run -t upload; pio device monitor -b 115200


If you always want to upload and monitor whenever using pio run, then add:
[env]
targets = upload, monitor
upload_protocol = esptool
upload_speed = 115200
monitor_speed = 115200


Nowadays, CLion has a PlatformIO plugin as well, including a menu Tools, PlatformIO with commands such as Re-init.



16647: <p>Please, help me to set up Clion + Arduino. </p>

<p>Clion has an Arduino plugin which I've installed. Here is some instruction on Github but I'm fully noob about <code>cmake</code> and other things which are talking about in instruction. I have only used Arduino IDE before for my simple projects. Now in CLion I can create an Arduino projects but autocompletion doesn't work. Actually it works but does it on true C, not for Arduino code. </p>

<p>So if you can please explain like for complete idiot, what I should change to get working Arduino autocompletion. </p>
 19671: <p>I know this was asked a long time ago, but maybe it will be useful for someone. I'm a beginner, regarding all this stuff, so if anybody knows a better way to do it, please correct me. here is how I set up CLion for Arduino (on Windows 10):</p>

<p>CLion 2016.1.3 + Arduino 1.6.9 + plugin</p>

<ol>
<li><p>Download and install the official Arduino IDE (1.6.9).</p></li>
<li><p>Download and install <a href="https://sourceforge.net/projects/mingw/files/latest/download?source=files" rel="noreferrer">MinGW</a> to 'C:\MinGW'</p></li>
<li><p>In MinGW, install: 'mingw32-base' and 'mingw32-gcc-g++'</p></li>
<li><p>Download and install <a href="https://www.jetbrains.com/clion/download/#section=windows-version" rel="noreferrer">CLion</a>.</p></li>
<li><p>Create an 'untitled' project, just to open CLion.</p></li>
<li><p>In CLion > Settings > Plugins > Browse Repositories > Search for and install: 'Arduino' (tools integration), and 'Serial Monitor' (misc).</p></li>
<li><p>In CLion > Settings > Search > type 'MinGW'</p></li>
<li><p>At the environment select 'Use MinGW home', and browse to MinGW folder ('C:\MinGW'). Press apply, and wait until CLion finds the environment.</p></li>
<li><p>In File > Close project.</p></li>
<li><p>Open any file manager and go to 'c:\Users\name\ClionProjects\' and delete the 'untitled' project you just created.</p></li>
<li><p>Open CLion, select 'New Arduino sketch project'</p></li>
<li><p>In the project directory > 'open cmakelists.txt' and configure lines:</p>

<pre><code>6: set board version
7: set port (you can find out port# from the Arduino IDE)
8: set the path where you installed your Arduino libraries (Arduino sketch folder)

set(${CMAKE_PROJECT_NAME}_BOARD uno)
set(${CMAKE_PROJECT_NAME}_PORT COM3)
LINK_DIRECTORIES(c:\\ARDUINO\\libraries)
</code></pre></li>
<li><p>In the upper right corner in CLion, near the green 'Play' button, select 'Edit Configuration', on the left select 'Application' > 'Upload', and set:</p>

<pre><code>-target: 'upload'
-configuration: 'debug'
-executable: the project name
</code></pre>

<p>then press ok.</p></li>
<li><p>In the project .ino file, write some really simple code (blink).</p></li>
<li><p>Connect an Arduino Uno via USB, and press the green 'play' button to upload the sketch.</p></li>
<li><p>To start serial monitor:</p>

<ul>
<li>In CLion main window bottom left, click serial monitor tab (in 'the tool buttons')</li>
<li>Click the wrench icon to set up port and baud rate.</li>
<li>On the top of the wrench icon, click the blue 'connect' icon.</li>
<li>If values did not appear 'correctly', click the white 'switch to hex' icon (on the right of the wrench).</li>
<li>Before uploading sketch, disconnect the serial monitor.</li>
</ul></li>
<li><p>For CLion to properly find the libraries, make sure to use the same name for the lib folder as for the '.h' file. example: for DallasTemperature.h use folder name DallasTemperature. After #inlcude-ing new libs, right click on 'External libraries folder' and select 'Reload cmake project'.</p></li>
<li><p>You may want to do further configuration in CLion settings like: theme, colours, text size, etc.</p></li>
<li><p>Also, you can configure some handy 'live templates', like: <code>serialprintln</code>, <code>digitalwrite</code>, <code>pinmode</code>, <code>switch</code>, etc. to enhance your productivity.</p></li>
</ol>
 16852: <p>Rather than using any plugin, I am using CLion with <a href="http://platformio.org/" rel="nofollow noreferrer">PlatformIO</a>, which supports several IDEs. CLion then not only gives you code completion, but also full support for refactoring, Git, and much much more.</p>
<p>From <a href="https://docs.platformio.org/en/latest/integration/ide/clion.html" rel="nofollow noreferrer">its documentation</a>:</p>
<blockquote>
<p>[...] generate project via <code>platformio init --ide</code> command:</p>
<pre><code>platformio init --ide clion --board %TYPE%

# For example, generate project for Arduino UNO
platformio init --ide clion --board uno
</code></pre>
</blockquote>
<p>Then import the project in CLion and you're about done.</p>
<p>Some hints:</p>
<ul>
<li><p>Make sure your code is in the <code>src</code> folder, and that the main file has a <code>.cpp</code> extension.</p>
</li>
<li><p>For other files: either rename all <code>.ino</code> files to use <code>.cpp</code>, or tell CLion to associate the <code>.ino</code> extension with C++ files. (Preferences, Editors, File Types.)</p>
</li>
<li><p>Whenever adding libraries to the <code>lib</code> folder (and using <code>#include</code> to refer to them), just run the above <code>init</code> command again.</p>
</li>
<li><p>If you're using ESP-boards and changed <code>platform.txt</code> for an alternative <code>esptool</code>, then note that PlatformIO <a href="https://arduino.stackexchange.com/questions/20219/upload-with-esptool-fails-with-espcomm-send-command-cant-receive-slip-payload/20220#20220http://">needs a different hack</a>.</p>
</li>
<li><p>Rather than using the CLion Serial Monitor plugin, I simply use a Terminal within CLion to upload and start the monitor as soon as possible:</p>
<pre><code>pio run -t upload; pio device monitor -b 115200
</code></pre>
</li>
<li><p>If you always want to upload and monitor whenever using <code>pio run</code>, then add:</p>
<pre><code>[env]
targets = upload, monitor
upload_protocol = esptool
upload_speed = 115200
monitor_speed = 115200
</code></pre>
</li>
<li><p>Nowadays, <a href="https://plugins.jetbrains.com/plugin/13922-platformio-for-clion" rel="nofollow noreferrer">CLion has a PlatformIO plugin</a> as well, including a menu Tools, PlatformIO with commands such as Re-init.</p>
</li>
</ul>
