Best way to Learn the code of Arduino

Hello I am new to Arduino and getting to learn new things from it I have not done a lot of programing and was wondering what is the best way to memorize and write code so that when I am done with the book I don't always have to refer to it whenever I need somthing?

memorize?

I don't understand.

Sam1980:
Hello I am new to Arduino and getting to learn new things from it I have not done a lot of programing and was wondering what is the best way to memorize and write code so that when I am done with the book I don't always have to refer to it whenever I need somthing?

Welcome to the Arduino forum and you have a very good question.

Others will have different answers, but memorization doesn't work for me. There are just too many variables.

I always use another program or other programs for reference. You have all the examples of programs in the Arduino IDE. You also have examples of Arduino C++ coding with all the various sensors, controllers and breakout boards. Use them for reference.

Your job is to understand the logic of what you are looking at and how to apply it to your current question. Every program can be written a different way and still accomplish the goal.

Paul

With practice you'll learn the basic language structure & syntax and some functions/keywords but you'll probably never learn/memorize the entire Arduino language. And if get that good, you'll be using additional libraries to do more advanced stuff and you'll need to check the references for them.

I'm not an expert programmer but I've done a lot of programming in different programming-languages and I'm always checking the language reference.

The basic/core Arduino language is reasonable and you can learn what most of the functions are, but you might have to check the details (or the spelling). i.e. You can learn and remember that there's an analogRead() function but if you don't use it everyday, you might have to check the reference.

The "real" C++ language is huge and there's not even a book that covers the whole language (except for the ANSI/ISO language standard itself). And, things like Windows programming or graphics, or the mouse, or audio are all additional, libraries on top of the C++ language. (Most of the Arduino stuff is additional to standard C++.)

I don't want to imply that programming is easy... It's hard and it's "different" that any other field. But, the Arduino is a pretty-easy introduction to programming and an easy way to learn. The hard thing about the Arduino is that you also have to know/learn some electronics too.

But the best way to learn almost anything is to take a class, and of course most professional programmers have gone to school. Sometimes it's hard to learn from the Internet or from a book because they usually teach you the programming language without teaching you about programming.

P.S.
The two most important concepts in programming are conditional execution (if statements, etc.) and loops (doing something over-and-over, usually until some condition is reached).

There's a LOT more to programming, but once you understand those concepts you can start to develop programs.

The things you use a lot you will naturally memorize, like the structure of a for() loop. Less often used things, like certain string functions, not so much. That's why there are reference materials.

As far as the problem of the moment goes, use descriptive, meaningful variable names. Saving a few keystrokes now with something like 'vc1' will bite you in the a$$ later during troubleshooting - especially as programs grow larger/more complex. Use comments freely. No matter how familiar you become with the code while perfecting it, six months down the road it will be well nigh impenetrable without good comments. A [style guide](C++ Programming Style Guidelines Conventions) is good to have handy too.

p.s. use descriptive variable names

Go watch this guy on you tube and he will teach you heaps.

Search up JEREMY BLUM ARDUINO SERIES.

Sam1980:
so that when I am done with the book I don't always have to refer to it whenever I need somthing?

I have been dabbling with programming for over 45 years. I don't remember everything. i just look things up. That is much easier now with the internet.

The things I remember are the general concepts such as the fact that there are arrays and how they can be used, the fact that there are functions to convert from character strings to numbers, functions to strip whitespace from the ends of strings etc. But more often than not I forget the exact name of the function and exactly how it is used - especially when switching between programming languages.

...R

especially when switching between programming languages

Very true, I switch all the time between Python and C at the moment and it is amazing how my indentation of C code, which does not matter, now looks like my indentation of Python where it is a vital part of the syntax.

As others have said you never remember it all, don’t even try. The more you do the more you will remember, but you will never remember all but a most trivial sub set of a language.