Learning C++

Hello,

I have couple of projects in mind, and before I ask questions about the code and multiple more questions, I'd like to ask the following:

  1. What book do you guys recommend to learn C++ programming?
  • I'd like to not just copy and paste a code, but be able to do modifications and be sure of what I am doing.
  1. Besides a book to learn C++, do you recommend any other material that can be helpful during the starting process?

  2. Is YouTube the best way to learn about Arduino IDE?

Thanks for your time,
Leo

Look through these links:

Arduino links of interest.

How to use this forum:
https://forum.arduino.cc/index.php?topic=149014.0

Listing of downloadable 'Arduino PDFs' :
Either Google >>>- - - - > arduino filetype: pdf
Or
https://www.google.ca/search?q=arduino+filetype%3A+pdf&rlz=1C9BKJA_enCA739CA739&oq=arduino+filetype%3A+pdf&aqs=chrome..69i57j69i65.1385j0j7&hl=en-US&sourceid=chrome-mobile&ie=UTF-8

Listing of downloadable 'C++ PDFs' :
Either Google >>>- - - - > C++ filetype: pdf
Or
https://www.google.ca/search?q=c%2B%2B+filetype%3A+pdf&rlz=1C9BKJA_enCA739CA739&oq=c%2B%2B+filetype%3A+pdf&aqs=chrome..69i57.22790j0j7&hl=en-US&sourceid=chrome-mobile&ie=UTF-8

Arduino cheat sheet:

Watch these:
Arduino programming syntax:

Arduino arithmetic operators:

Arduino control flow:

Arduino data types:

Understanding Destructive LC Voltage Spikes:

OR

Why MOSFET gate resistors:

Some things to read

LCD information:

OR

Reading a schematic:
https://learn.sparkfun.com/tutorials/how-to-read-a-schematic

Language Reference:

Foundations:

How and Why to avoid delay():
http://playground.arduino.cc/Code/AvoidDelay

Demonstration code for several things at the same time.
http://forum.arduino.cc/index.php?topic=223286.0

Multitasking:
Part 1:

Part 2:

Part 3:

Sparkfun Tutorials:
https://learn.sparkfun.com/tutorials?page=all

Micro Controllers:

Useful links:
https://forum.arduino.cc/index.php?topic=384198.0

Arduino programming traps, tips and style guide:

Call for useful programming discussions
https://forum.arduino.cc/index.php?topic=383980.0

Jeremy Blume:

Arduino products:

Motors/MOSFETs

Switches:

Share tips you have come across, 500+ posts:
https://forum.arduino.cc/index.php?topic=445951.0

Images from above:
https://www.google.com/search?q=“Share+tips+you+have”+larryD+site:https://forum.arduino.cc&prmd=nmvi&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiJw-zu68ncAhXPGTQIHWCDCNwQ_AUIFCgE&biw=1024&bih=653

Debug discussion:
https://forum.arduino.cc/index.php?topic=215334.msg1575801#msg1575801

Frequently Asked Questions:
https://www.arduino.cc/en/main/FAQ#toc10

Number 'type's.

  • boolean (8 bit) - simple logical true/false, Arduino does not use single bits for bool
  • byte (8 bit) - unsigned number from 0 to 255
  • char (8 bit) - signed number from -128 to 127. The compiler will attempt to interpret this data type as a character in some circumstances, which may yield unexpected results
  • unsigned char (8 bit) - same as 'byte'; if this is what you're after, you should use 'byte' instead, for reasons of clarity
  • word (16 bit) - unsigned number from 0 to 65535
  • unsigned int (16 bit)- the same as 'word'. Use 'word' instead for clarity and brevity
  • int (16 bit) - signed number from -32768 to 32767. This is most commonly what you see used for general purpose variables in Arduino example code provided with the IDE
  • unsigned long (32 bit) - unsigned number from 0 to 4,294,967,295. The most common usage of this is to store the result of the millis() function, which returns the number of milliseconds the current code has been running
  • long (32 bit) - signed number from -2,147,483,648 to 2,147,483,647
    float (32 bit) - signed number from -3.4028235E38 to 3.4028235E38. Floating point on the Arduino is not native; the compiler has to jump through hoops to make it work. If you can avoid it, you should. We'll touch on this later. Sparkfun.

You select the 'type' best suited for your variables.

ex:

  • your variable does not change and it defines a pin on the Arduino. const byte limitSwitchPin = 34;
  • since an analog variable can be 0 to 1023, a byte will not do, you can select 'int'. int temperature;
  • if your variable needs to be within -64 to +64 a 'char' will do nicely. char joystick;
  • if your variable is used for ASCII then you need type 'char', char myText[] = {"Raspberry Pie Smells"};
  • if your variable enables some code then boolean can be used. boolean enableFlag = false;
  • millis() returns the time in ms since rebooting, unsigned long currentTime = millis();
    etc.

Oh, and have fun too :slight_smile: !

Believe it or not, I will make sure I read and evaluate all that information, I am really excited to start learning from the beginning this technology.

I am having fun since now!

Thanks for sharing that information,
Leo

one of the best books i read on how to write good programs was The Elements of Programming Style by kernighan and plauger and only about a 1/4" thick. kernighan later wrote The C Programming Language. progamming style showed textbook programs, identified and fixed their flaws and how to make them better

kernighan edited C++ Prgramming Style by cargill which similarly shows what look like good C++ programs, discusses their flaws and how to write them properly.

@Leoaven, the answer really depends on where you are now. What's you coding skill level? Do you already know 'C'?

@gfvalvo,

I have manipulated 2 or 3 codes for some personal projects. I consider they were just few modifications such as commenting out some lines, changing I/O pins to match my Arduino board, installing libraries.

Not much of a good foundation of 'C' itself. I'd like to be able to write my own code, at least a 10 lines code, that's something wouldn't be possible right now,

Thanks,

Leo

OK, then never mind. The book I was going to recommend is meant to help experienced C programmers transitions to C++.

It really depends on how you like to learn and what your goal is. If you find a C or C++ tutorial and work through it until you can use arrays and write functions, that'll be sufficient to get started on coding for Arduino.

I rather suspect that most people don't bother with that and learn by hacking existing code and getting help here when they get stuck.

If you work through all the material that larryd linked, I expect you will be the one dispensing advice.

It may help to have a project in mind to guide you in choosing what to learn first.

I have found the YouTube channel Core Electronics “arduino workshop for beginners” to be very useful and set at the right pace for beginners.

I would rather write programs to help me write programs than write programs.

Dick Sites