Pages: [1]   Go Down
Author Topic: C or C++  (Read 27590 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 49
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the arduino environment accept C only, or can you use C++?   I am interested in learning a little more about programming for the arduino, but dont want to spin my wheels in the wrong direction.
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use C++. In fact, a couple of the libraries around use object-oriented programming: Wire for one, and some of the LCD libraries. The hardware Serial interface also has its library written in C++.
Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think all the Arduino supplied libraries are written in C++ and any sketch using these libraries is using C++ constructs.

If you are more interested in interacting with digital and analog i/o,  then the C language with the Arduino abstractions can get you pretty far. But if you are seeking to implement larger or more complex problems, or just want to learn to use the rich expressive power of the C++ language in order to become a proficient programmer, then time learning C++ would be an interesting and worthwhile journey.

I think a good approach is to concentrate on the core C functionality to get your early sketches going while reading and absorbing the underlying concepts of C++. But feel free to jump in the deep end if you so desire.

Anyway, have fun!
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 72
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see several books entitled c programing for microcontrollers or embedded systems and the like, none of which cover the Arduino platform.  Then I see bools like C Primer Plus or C++ Primer Plus, which get great ratings and are quite thick might I add.  I guess my question is would getting a straight c/c++ programing book be overkill, taking me in directions not relevant to microcontrollers, or should I be waiting for a book entitled C Programing for Microcontrollers with the Arduino?

I don't want to spent $50 to $100 on a book that won't do the job.

Thanks

P.S. I think I speak for several newbs like myself when I say why has no one written that last book i mentioned? smiley-wink
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6371
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think a lot of the C++ books you see will spend a lot of time explaining the many classes that are used when creating typical windows GUI applications, rather than the language itself.  A book on C for microcontrollers is probably more useful.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 9
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, note that Arduino (and the underlying avr-g++ compiler) doesn't support all of C++, so a lot of stuff that you read about in a C++ book won't work.  Details here: http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_cplusplus
Logged

Pages: [1]   Go Up
Jump to: