Configuring Netbeans for Arduino Development

After spending some time using Eclipse and Arduino IDE for Arduino development, I’ve decided enough is enough! No longer will I put up with the unbearable hardship of using some other IDE. It’s NetBeans or bust! Well, it was a long road, but I’ve made it. If you’d like to make it too, then I can help.

Arduino IDE

First, we need to install the Arduino IDE. On Ubuntu, this is a simple apt-get:

sudo apt-get install arduino arduino-core gdb-avr

When that is finished, run the Arduino IDE.

Click Add when prompted about Dialout permissions

Enter your password

Before we can continue, we must logout, then log back in for the updated permissions to take effect.

Verify it works

Open Arduino IDE

Click File -> Examples -> 01.Basics -> Blink

A new window should launch with code for the basic blink program.

Plug your Arduino Uno into your computer via usb port. Click Tools -> Serial Port and select the correct Serial port

Click the Upload button on the toolbar. If all is well, your Pin 13 LED should start blinking.

Netbeans configuration

Launch Netbeans

Click Tools -> Options

Click on the C/C++ tab

In the bottom left corner, click Add…

In the Base Directory: field, enter the location of your AVR tool collection. apt-get put mine at /usr/bin

In the Tool Collection Family: dropdown, select GNU

In the Tool Collection Name: field, enter Arduino. Click OK when done

The various commands will be populated with the standard GNU toolkit commands. This is not what we want. Change them all to their avr equivalents: avr-gcc, avr-g++, avr-as, and avr-gdb. There is no avr-make, so leave it as the standard make. Feel free to clear the QMake Command: field.

Click the Code Assistance tab. Ensure the Tool Collection: dropdown has your Arduino toolchain selected and that the C Compiler tab is selected

Add arduino libraries. These are:

/usr/share/arduino/hardware/arduino/cores/arduino /usr/share/arduino/hardware/arduino/variants/[VARIANT] /usr/share/arduino/libraries

Click C++ Compiler. Add the same libraries as above

Click OK

The Plugin

For our plugin, we’ll be using arduino-netbeans by Jaques Claudino

Click the above link, and navigate to Downloads. Download the latest Linux plugin.

When the download is completed, return to NetBeans.

Click Tools -> Plugins and click the Downloaded tab

Click Add Plugins…

Browse to the location of the downloaded plugin, select it, and click OK

Click Install

Follow the wizard.

When prompted about an untrusted certificate, we might as well click Continue. After all, we are downloading software made by Some Guy, it’s not going to be signed by VeriSign or somesuch.

Click Finish when done.

Click Close.

Verify it works

Click File -> New Project…

Select Arduino and click Next >

Give your project a name, and click Finish.

First, open up the Makefile for your project, we have some changes to make

As the comments at the top of the Makefile say, we need to make some changes. First set COM_PORT to be the correct serial port.

Next Set ARDUINO_BASE_DIR to the correct installation path. For me, that is /usr/share/arduino

Next, uncomment the correct configuration. Since I am using an Uno, there is no change for me. However, if you have a different board, comment the Uno section and uncomment the correct board.

We should officially be set. In your main.cpp, implement the blink program. I recommend copying and pasting the one provided by Arduino IDE that we used previously. Be sure you don’t delete the #include and extern HardwareSerial Serial; lines.

When you are ready, click Clean and Build. Then click Run. If all is well, your onboard Pin 13 LED should blink.

10 responses to “Configuring Netbeans for Arduino Development”

  1. Jeff O'Brien says :

    I already have arduino 1.0.5 loaded and netbeans. I use them both daily. Your first step is to apt-get the arduino core. Is there some way to alter your instructions to base all paths to the arduino 1.0.5 installation as I believe everything needed is already there? I’m just a bit afraid of messing up my current working setup by loading the core. I’m using Ubuntu 10.04LTS and netbeans. I desperately want to stop using the arduino IDE. Also I do not use the boot loader and I upload my programs using the “upload using programmer” option in the arduino file menu. I use the AVRMKII icsp programmer. Wondering what changes would need to be made to support this option as well. Thanks in advance.

    Like

  2. Chris says :

    If you already have the arduino stuff installed, you shouldn’t need to re-install it. You should just be able to follow the rest of the instructions, making sure to update paths in the toolchain config and makefile config to be correct.

    As far as using a non-standard programmer, I don’t know. The whole plugin is based around a customized Makefile, so you may be able to edit that. Looking through mine just now, I see a stanza called upload:, which seems to call the command line for AVR_DUDE. That might be a good place to look. I just use AVR_DUDE, so I’ve never had to mess with that.

    Assuming you can make that work, you might want to let the Plugin author know at the plugin website

    Like

  3. Jeff O'Brien says :

    I guess what is tricky is that i just downloaded the latest arduino 1.0.5 build from the website and extracted it in my home directory. so everything is self contained in a folder called /home/jeffob/arduino-1.0.5
    under there i can find hardware/tools/avr and here is where i think my tool collection is. so i have to some how translate your directions from /usr/bin and /usr/share to the standalone arduino folder which is what is tripping me up. i’m wondering if you have the time to just download the arduino 1.0.5 tarball and then try pointing netbeans to all of the necessary items within this directory and see if it works for you. no big deal if you don’t have the time…
    thanks
    Jeff

    Like

  4. phil says :

    hello,

    on linux,it seems the arduinocore.a (v5) is not compatible with mega(v6)

    /usr/lib/gcc/avr/4.7.2/../../../avr/bin/ld: avr:5 architecture of input file `lib/core/arduinocore.a(main.cpp.o)’ is incompatible with avr:6 output
    /usr/lib/gcc/avr/4.7.2/../../../avr/bin/ld: avr:5 architecture of input file `lib/core/arduinocore.a(wiring.c.o)’ is incompatible with avr:6 output
    /usr/lib/gcc/avr/4.7.2/../../../avr/bin/ld: avr:5 architecture of input file `lib/core/arduinocore.a(wiring_digital.c.o)’ is incompatible with avr:6 output

    anyone wknows where to find the compiled lib ?

    Like

  5. greypanda says :

    Great instructions. Do you have any idea where the “template” for the makefile is stored? It is a real pain to have to change the path for every new project.

    Like

  6. greypanda says :

    One more thing. I had to change the ‘AVR_DUDE = ${AVR_DUDE_WINDOWS}’ to ‘AVR_DUDE = ${AVR_DUDE_LINUX}’ to get the upload to work.

    Like

  7. Chris says :

    Unfortunately, I don’t actually have this plugin or NetBeans installed at the moment, so I can’t check the location of the makefile template.

    That said, it should be in the netbeans install folder. Try to cd into the netbeans folder and then find ./ -name makefile should turn it up.

    Like

Trackbacks / Pingbacks

  1. Learning to Arduino: the LED | Doing My Programming... - August 30, 2013
  2. Netbeans a arduino | blog - April 1, 2014

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: