0

I am an experienced web developer, but my C++ skills are very basic. I struggle with the concepts because it is so different from something like Javascript (which I already know). I do not have a lot of time to learn C++, and I only need to know enough to play with Arduinos.

Are there any good resources out there for learning C++ that is specifically geared towards Arduino programming, and is there anything interactive like Codecademy?

  • 1
    Bad news: Arduino uses C++. And C++ is harder than C. – Ignacio Vazquez-Abrams Apr 14 '15 at 1:00
  • My bad. Like I said I have done a little Arduino programing but clearly I know very little. – user8452 Apr 14 '15 at 1:03
  • @IgnacioVazquez-Abrams - Good news: ANSI C will still compile with the Arduino IDE. – Comintern Apr 14 '15 at 1:09
  • Well I would like to learn whatever the Arduino IDE uses as default and whatever else most people use. – user8452 Apr 14 '15 at 1:10
  • 1
    @Comintern: And yet most of the Arduino libraries use C++. – Ignacio Vazquez-Abrams Apr 14 '15 at 1:21
3

If I were you I'd take the high road.

I was in your shoes a while ago and I didn't know how to approach Arduino. I was very lucky that I came across a book written by the famous Jack Purdum, "Learn C programming for the Arduino". It is written by a retired Purdue University professor who is well known for his extremely easy to learn teaching method. He has another

I only knew MATLAB and Simulink before starting this book. This book is amazing. It was extremely easy to follow. I now have no difficulty programming Arduino in the correct way. This book trains you to optimize everything which is very crucial with the limited resources on Arduino boards.

I suggest C instead of C++. It is the language of choice for programming embedded system. It is said to be low level, but as a MATLAB user I should tell you that syntaxes are extremely easy and intuitive. I didn't find anything hard about them.

Remember:

  1. There isn't any problem to use C in Arduino IDE.

  2. You don't need to worry about libraries. You only need to load them in the beginning of the code. You do not need to know how was the code written in the library.

  3. Check the comments about the book on Amazon if you are not convinced.

Good Luck

  • 1
    It's worth noting that a little C++ knowledge is quite important for using many of the common Arduino libraries. – Peter Bloomfield Apr 14 '15 at 10:59
  • I must admit that I am not familiar with C++. On the other hand, to this day I haven't had any problem with any libraries. I just load them. But I don't know if I will need to use C++ in the simple projects. I'd be thankful if you could elaborate on this. Make a few examples where knowledge of C++ is crucial for using already written libraries. Thank you in advance. – arudino.tyro Apr 14 '15 at 11:03
  • 1
    In many cases, the library interface is a class. You have to instantiate it and call member functions on it in your code (e.g. see SoftwareSerial). It's certainly possible to just copy and adapt example code. However, I'd always recommend that at least a little knowledge of object orientation is important in understanding how to use it effectively. – Peter Bloomfield Apr 14 '15 at 11:45
  • 1
    Some newer C features won't work in the IDE, which is a shame since __flash is so very handy. – Ignacio Vazquez-Abrams Apr 14 '15 at 13:45
1

A very good book: Beginning C for Arduino:Learn C Programming for the Arduino, by Ph.D. , Jack Purdum

0

Another way to approach the problem is to come up with a project that you want to do with an Arduino and look for code samples. Since you already have some programming experience you should be able to pick up what's going on pretty quickly and you will have a vested interest in what the code is doing.

For Example: Read temperature from a sensor and display to an LCD.

Arduinos are really good for reading from a sensor and there's a huge arduino community. So, if you start with just reading from different types of sensors you'll find a lot of examples and learn a lot about Arduinos at the same time.

0

Beginning C for Arduino:Learn C Programming for the Arduino, by Ph.D. , Jack Purdum

0

Since you have programming experience and you say you only want to learn enough to play with Arduinos, I think a resource worth mentioning is the built-in example programs. I've seen Arduino itself used as a learning tool for C/C++; their examples are very basic and intended for complete novices. If you keep hacking on progressively more complicated examples and googling specific things you don't understand, you will probably be able to get a good handle on things IMHO.

That isn't to say it's necessarily a good tool for learning C++ in general, since the limited memory resources and 8-bit CPU make some capabilities of the language commonly used on desktops (and the whole standard library) rarely used or unavailable on Arduino.

  • I have played with the examples and the most complicated thing I built used shift registers. What confuses me the most is all the variable types. Javascript is so simple but C++ is so fussy. – user8452 Apr 14 '15 at 1:38
  • @ChristianJuth The reason there are so many types, is to make efficiënt use of your memory. But you can actually use Int (for integer values), float for decimal and strings for text. The other types or sub-types are to make them a little longer or smaller :) or to define wethether they can be negative (signed or unsigned) ontop of that you have boolean for true or false. – Paul Apr 14 '15 at 16:28

Your Answer

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