Home Using QtCreator for Arduino Development

Using QtCreator for Arduino Development

 
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

About ReadWrite’s Editorial Process

The ReadWrite Editorial policy involves closely monitoring the tech industry for major developments, new product launches, AI breakthroughs, video game releases and other newsworthy events. Editors assign relevant stories to staff writers or freelance contributors with expertise in each particular topic area. Before publication, articles go through a rigorous round of editing for accuracy, clarity, and to ensure adherence to ReadWrite's style guidelines.

Get the biggest tech headlines of the day delivered to your inbox

    By signing up, you agree to our Terms and Privacy Policy. Unsubscribe anytime.

    Tech News

    Explore the latest in tech with our Tech News. We cut through the noise for concise, relevant updates, keeping you informed about the rapidly evolving tech landscape with curated content that separates signal from noise.

    In-Depth Tech Stories

    Explore tech impact in In-Depth Stories. Narrative data journalism offers comprehensive analyses, revealing stories behind data. Understand industry trends for a deeper perspective on tech's intricate relationships with society.

    Expert Reviews

    Empower decisions with Expert Reviews, merging industry expertise and insightful analysis. Delve into tech intricacies, get the best deals, and stay ahead with our trustworthy guide to navigating the ever-changing tech market.