small medium large xlarge

Back to: All Forums  Arduino
Generic-user-small
26 May 2010, 19:01
Michael Weller (6 posts)

I’m really interested in tinkering with embedded systems. The code in the excerpts looks like C or C++. Ideally I’d love to be able to play with plain old C but I can’t quite tell what the language is. I noticed .h headers, but .pde source files and some possible Object.method() syntax. Could someone clarify?

Mike

Dsc00765_pragsmall
27 May 2010, 12:52
Susannah Davidson Pfalzer (114 posts)

Hi Mike,

Thanks for asking! The Arduino programming language is C++. Here’s some sidebar text from Chapter 2 in the book, which should help clarify:

People sometimes seem to be a bit irritated when it comes to the language the Arduino gets programmed in. That’s mainly because the typical sample sketches look as if they were written in a language that has been exclusively designed for programming the Arduino. But that’s not the case— it is plain old C++ (which implies that it supports C, too).

Every Arduino uses an AVR microcontroller designed by a company named Atmel. (Atmel says that the name AVR does not stand for anything) These microcontrollers are very popular and many hardware projects use them. One of the reasons for their popularity is the excellent tool chain that comes with them. It is based on the GNU C++ compiler tools and has been optimized for generating code for AVR microcontrollers.

That means you feed C++ code to the compiler that is not translated into machine code for your computer but for an AVR microcontroller. This technique is called cross-compiling and is way to program embedded devices.

Best, Susannah Davidson Pfalzer Pragmatic Bookshelf

You must be logged in to comment