Help me start IDE coding in C++

Thread Starter

Mozee

Joined Jul 23, 2016
87
Hello AAC fellows,

I would like to start programming MCU such as Arduino and probably PICs afterwards. I am totally new to coding, I have ZERO background for any coding language, however, I am interested in C++ because it is widely used language.

The main thing is that I don't want to loose time learning things that might not be used for micro-controllers. I want to learn what is related to electronics and not general coding if possible!

For a start I want to start learning programming Arduinos at first because they are simple and so I can learn Coding at the same time. I tried the Arduino language and watched some tutorials and made a blinking LED etc but I want to start raw, plain C++ and build up knowledge like that instead of a simplified C/C++ instructions in a function.

How do i achieve that?
Any good books I can read?
I need a solid first step, a solid ground so I can build up on it. Any help is highly appreciate. Thank you
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
The Arduino does not use C++. In fact, C++ is very rarely used on any microcontroller, though it is sometimes available for larger chips where there is a large amount of RAM, such as the PIC32 series.

C is widely used in microcontrollers, and I believe the code for Arduino is in a language quite similar to C.
 

MrChips

Joined Oct 2, 2009
30,813
The main thing is that I don't want to loose time learning things that might not be used for micro-controllers. I want to learn what is related to electronics and not general coding if possible!
Then you don't want to learn C++. Like what Ernie says.

Have you heard of something called ASM?
 

MrSoftware

Joined Oct 29, 2013
2,201
You can code for Arduino using any language that offers an Arduino compiler. I don't code for micro controllers often, but I've written Arduino code in C++ using the Atmel compiler, it works fine. C++ is great for when things start getting complicated. Using classes and objects can really help to simplify things when your program starts to become complex, though sometimes at the expense of code size and/or efficiency at execution time if you're not careful.

Learn C first, then worry about C++. The basics of the language will be the same regardless of which platform you're coding for, so worry about applying it to micro controllers after you have an understanding of the basics. Your life will be much easier if you're not struggling with the language at the same time that you're trying to learn the hardware.

O'Reilly usually has good books (they use animals pictures on the covers), and any book by Stroustrup should be good. Since micro controllers don't typically have wads of RAM, be sure to understand memory allocations and scope. Understand the difference between heap and stack allocations, and the potential pitfalls of using a lot dynamic allocations/deallocations (memory fragmentation). Also understand variable size, and the sizeof() operator, as well as what happens when variables aren't the size you think they are. i.e. what if you try to assign a value greater than 255 to a 1-byte variable, etc.. Also understand bit-wise operators and all of the compilation steps. You'll see a lot of macros, which are handled in the preprocessor compilation step. As I mentioned above, I don't code for micro controllers often, but the little bit that I did do was fairly complex and knowing the language well really helped me understand what the hardware should be doing, which makes debugging hardware problems much easier.
 
Last edited:
Top