github email rss
Some notes on using the arduino sdk with the arduino-makefile
Jan 6, 2017
2 minutes read

These are some notes after fiddling around with the arduino sdk and the arduino-makefile. If you followed the install on my previous blog entry, you should now be able to compile a simple sketch and upload it to the arduino (e.g. the blink program).

First of all you should save your source files with .ino extension. .c or .cpp do not seem to be picked up by the makefile.

Now, to use any external libraries to drive some components, there are 2 ways I found to do it. Usually libraries come with a header file and a .cpp implementation file. You can place them in the same directory as your project, and after changing your headers to look in the current dir (i.e. replace the with “mpla.h”) and running make, the arduino makefile will pick them up, compile them and link them to your binary.

But things can get messy, especially if you want to use multiple libraries, or if these libraries require other standard libraries (like the SPI). In my case, I wanted to use a DHT11 thermometer to get the temperature and humidity and display it on a 16x2 LCD display.

A library for the latter already comes with the arduino sdk and is located in /path/to/arduino-sdk/Arduino/libraries and it’s called LiquidCrystal. To use this in your sketch, you must tell the Arduino-Makefile to include it in your project, so add this to your Makefile:

ARDUINO_LIBS := LiquidCrystal

This should build the example sketch for the display from

To use the thermometer, download the library from: It’s basically a .h and a .cpp file. Create a directory in /path/to/arduino-sdk/Arduino/libraries/DHT11 and copy them there. Then, include them in your project libs:

ARDUINO_LIBS := LiquidCrystal DHT11

Back to posts