Introduction

I’ve been using QtCreator for some time now, mostly for Qt projects, and I really like the environment. It’s fast and have plenty of features for c/c++ development such as code completion, symbol navigation, and git integration.

Today I decided to try if I could use QtCreator for Arduino development and it turned out that it wasn’t that difficult. The environment isn’t perfect but it works and it doesn’t take much effort to set up a project.

Disclaimer: I’m not doing Arduino development regularly, I just find it amusing to toggle bits on 8-bit hardware now and then. If you find anything in this post that seems totally wrong please let me know.

Prerequisites

This tutorial assumes that you’re running Ubuntu. It shouldn’t be too difficult to adjust for other Linux distributions.

If you haven’t already installed the latest QtSDK (1.1.3), please download it from http://qt.nokia.com/downloads and do so.

Install arduino-core package from the Ubuntu repository

$> sudo apt-get install arduino-core

This should pull in required dependencies too, such as avr-gcc and avrdude.

Install gtkterm (optional, but recommended)

$> sudo apt-get install gtkterm

Creating a simple ‘Hello World’ project

You can create everything from within QtCreator but I find it easier to do the initial set up from command line.

$> cd <projects folder>
$> mkdir -p helloworld/src
$> cd helloworld/src

If you look at the top of the file /usr/share/arduino/Arduino.mk you’ll find instructions on how to create a suitable Makefile for your project.

Here’s one that I use, just put the content in helloworld/src/Makefile

ARDUINO_DIR  = /usr/share/arduino

TARGET       = main
ARDUINO_LIBS =

MCU          = atmega328p
F_CPU        = 16000000

# Avrdude code
ARDUINO_PORT = /dev/ttyACM0
AVRDUDE_ARD_PROGRAMMER = arduino
AVRDUDE_ARD_BAUDRATE = 115200

include /usr/share/arduino/Arduino.mk

Finally create helloworld/src/app.cpp with the following content:

 #include <WProgram.h> void setup() { } void loop() { } 

Importing the Hello World project

Start QtCreator and go to ‘File/New File or Project’ (ctrl+n) and then choose ‘Other Project/Import Existing Project’.

 

Import-Projec-Qt-Creator-MeeGo-MeeGoExperts-600

 

Finish the wizard by specifying ‘HelloWorld’ as ‘Project name’ and ‘<projects folder>/helloworld’ as ‘Location’. You might wonder why I specified ‘helloworld’ as project location instead of ‘helloworld/src’. This is because I don’t want QtCreator’s project files to end up in the same folder as my source. Just click on ‘Next’ on the following questions to finish the wizard.

 

Import-Projec-Qt-Creator-MeeGo-MeeGoExperts-600-1

 

QtCreator creates three files:

  • HelloWorld.conf – Add defines
  • HelloWorld.files – List all files that are part of the project
  • HelloWorld.includes – List all include paths

Add ‘/usr/share/arduino/hardware/arduino/cores/arduino’ to ‘HelloWorld.includes’. This tells QtCreator where to look for Arduino specific header files.

Configuring ‘Clean/Build/Run’
Click ‘Projects’ (ctrl+5) on the bar to the left to activate the project settings page to change the build and run settings.

Clean and Build settings
Change ‘Build directory’ to ‘<projects folder>/helloworld/src’ and modify the settings to reflect the screen shot below.

 

Import-Projec-Qt-Creator-MeeGo-MeeGoExperts-600-2

 

Run settings
Choose ‘Add Deploy Step’ and use the screen shot below to specify the settings.

 

Import-Projec-Qt-Creator-MeeGo-MeeGoExperts-600-3

Source Jayway Team BlogImport-Projec-Qt-Creator-MeeGo-MeeGoExperts-Avatar