1

I will be using the Arduino platform with other data acquisition hardware for a school electronics project. I have limited knowledge of C++ syntax.

Are there good introductory to intermediate books that can bring a high school student with some programming experience to proficiency on Arduino?

1
  • IMHO the only way to learn it is to program it. So grab any arduino (UNO, Mega, Nano... I suggest you the mega 2560 because it'll be useful for more projects) and then go on the arduino website and follow the tutorials. Then choose a device (e.g. an LCD with Hitachi HD44780 controller) and search for "Arduino *", where * is the device; learn how to use it. Then move to the next one. The learning curve is not steep at all, and there are not many things to learn. Just, please, keep in mind that it is a MICROcontroller, not a PC. So avoid using complex structures. Keep it as simple as you can
    – frarugi87
    Dec 1 '15 at 9:40
1

I'd recommend you go to cplusplus.com. Plenty of tutorial pages and topics to further your knowledge. However, be aware that Arduino uses a variant of C designed for microcontrollers (the exact flavour depends on the microcontroller type/family), rather than C++, so do be aware that some of the topics are not implementable on an Arduino. That said, I can't think why you'd be using some of the more elaborate C++ exclusive features in a fairly middle-of-road embedded system.

The only thing you need to ignore in C++ is memory allocation specifics - you're limited to the 'original' malloc() based functions rather than the all-singing-all-dancing operator new from C++. If you are in need of memory allocation functions, malloc is well-documented and a tutorial is only a quick Google away.

Of course I must also point you in the direction of the highly popular Stack Overflow site, part of this Stack Exchange network. While they don't have tutorials, there are plenty of great answers to common questions.

5
  • Only Intel's arduinoesque offerings use uClibc. Jun 1 '15 at 18:34
  • Most Arduinos (notably not the Due) run AVR microcontrollers. On these, the Arduino core library is based on AVR Libc. Jun 1 '15 at 19:38
  • @Ignacio Vazquez-Abrams: I thought "uClibc" was a generic term for a specific hardware-orientated C libraries, not a specific one; I stand corrected. Answer edited to remove direct reference. Jun 1 '15 at 19:46
  • 3
    Also, Arduino (at least for some of the boards) does use C++ the language proper; only some library support (notably the entire STL) is missing. Jun 1 '15 at 20:13
  • Recent versions of the IDE support new and delete. Thus you can instantiate classes on the heap without any trouble (excepting possible memory fragmentation). Plus what @IgnacioVazquez-Abrams said. You can basically program in C++. The STL can be installed if you want it. However exceptions are not supported as far as I am aware.
    – Nick Gammon
    Jul 4 '15 at 5:21
1

I would start with a standard C++ introduction book to get an understanding for the language. After that I would read a book on object-oriented design and implementation.

There is a lack of books on how to systematically approach programming small scale embedded systems such as Arduino. Due to the restrictions on resources, both processing and memory, C++ has to be used "carefully". There is a need to understand some of the more difficult concepts such as volatile, virtual, ISR, etc.

Reading others code is also a very good way to learn. I would recommend looking at the source code and example sketches to Cosa. This is an OOP framework for Arduino/AVR.

Last but not least - learning by doing!

Cheers!

0

There is a book called "C Programming for Arduino" by Julien Bayle that introduces it pretty well if you are just getting started at it. I think it's from Packt Publishing.

Another I found interesting is called "Practical AVR Microcontrollers" by Alan Trevennor that gives examples of programming using C without having to get an Arduino.

Otherwise, Stack Exchange is always really great to browse.

1
  • You don't actually need an Arduino to use Arduino libraries though. They work just fine with discrete MCUs. Jun 1 '15 at 23:04
0

I found the Arduino examples a good reference for refreshing/learning C++.

Important Arduino C++ classes are:

To learn more about the syntax of the language, the inventor of C++ has also a couple of videos online.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.