Monday, April 6, 2015

Using the Arduino IDE to Program the Raspberry Pi and Other Devices

Ever wish you could prototype a Raspberry Pi program as easily as prototyping on Arduino?

The Arduino IDE allows nearly any processor to be programmed with the same easy to use language. Back in 2012, this was possible: it takes architecture changes by the Arduino group (, some programming by code library developers (,, many others), and from users to get all of this working.

The parts are now in place to do this: the latest Arduino IDE releases are in a new 1.6.x branch, the latest as of this article is 1.6.3.  This release is revolutionary in having the following:
  • A new library manager - libraries can be installed with several clicks from a website without downloading code and installing it in a specified place on the user's PC.
  • The capability to specify new boards that are not quite the same as Arduino boards. Companies have done this by hacks and creating special versions of the Arduino IDE which can get confusing after a bit.
  • A mechanism to easily specify and use code compilers other than the Atmel AVR.  The Atmel SAM series is available after installing the 1.6.3 version if you request it. 
In the same manner as the SAM (Arduino Due) capability can now be an add-on once the initial IDE is installed, other companies are working (quickly) to add the capability to incorporate their products. Obvious candidates include:
  • Non-Arduino Atmel AVR boards
  • Arduino "compatibles" - like the Teensy series which is very popular
  • Boards based on ARM cores Cortex M0, M0+, M3, etc.
Take this a step further.  While running "simple minded microcontroller code" on more powerful boards seemed nonsensical not long ago as cost inefficient, those costs have plummeted. Development boards using powerful processors have come down in price thanks to Raspberry Pi, BeagleBone, and many others.  The $50, $35, $25, $12, and $8 price points all have different boards that can be used.  Even at $2 to $5, new boards like the ESP8266 Wifi controller are coming in.  So, extend your thought to using the Arduino IDE to actually run Arduino code (not just program an AVR) on:
Some will say "Why Arduino?"  The Arduino IDE and language specification, started in 2005 and extended since, has a proven track record for allowing users to easily get code running that actually interacts with the "real world".  Millions of lines of Arduino code have been released under open source licenses, allowing reuse by anyone. With such a vast repository, why not leverage this onto other microcontroller and microcomputer architectures?  With the compatibility to use C and C++ code, it is even more compelling.

Raspberry Pi as an Arduino Target

If I have some interesting Arduino code, say for controlling a near-field card reader, and wanted to port this to Raspberry Pi, I'd face a tough choice.  Think about reprogramming in Python and hope there is manufacturer library support for Python, or consider programming in C and know that I'd have to rewrite the Arduino library to work on the Pi.  Unsavory choices.

If the Arduino IDE would create a Raspberry Pi Linux executable of my Arduino sketch (program), I'd be nearly done.  Due to differences in programmable pin (GPIO) numbering, some items would require changes but those are numbers and not wholesale code structure changes.
This could increase (rapidly) the available uses for a Raspberry Pi.

With a huge body of Open Source coders who may have the interest and time, I looks like there will be many more places where we will see Arduino code running.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.