Published on 02 Oct 2013 | over 4 years ago

*Click Below to Sign up for the free Arduino Video Course:*

*Click Below to Check Out the Premium Arduino Video Course:*

*Click Below to Read About This Topic on Our Website*

The coding language that Arduino uses is very much like C++ ("see plus plus"), which is a rather common language in the world of computing. As I have alluded to in previous lessons, the code you learn to write for your Arduino will be very similar to code you write in any other computer language - all the basic concepts remain the same - it's just a matter of learning a new dialect should you pursue other ventures.
The code you will be writing is called "human readable", that is, it will make sense to you (sometimes) and will be organized for a human to follow. Part of the job of the IDE is to take the human readable code and translate it into machine-readable code to be executed by the Arduino. This process is called compiling.

The process of compiling is seamless to the user. All you have to do is press a button. If you have some errors in your computer code, the compiler will display an error message at the bottom of the IDE and highlight the line of code that seems to be the issue. The error message is meant to help you identify what you might have done wrong - sometimes they are very explicit, like saying, "Hey - you forget a semi-colon", some times they are way out there.

Why would I be concerned with a semi colon you ask? A semi-colon is part of the Arduino languages syntax, the rules that govern how the code is written. It is sort of like grammar when you think of writing. Say for example we didn't use periods when we wrote - every one would have a heck of a time trying to figure out when sentences ended and started. Or if we didn't employ the comma, how would we convey a dramatic pause to the reader?

And let me tell you, if you ever had an English teacher with an overactive red pen, the complier is 10 times worse. In fact - your programs WILL NOT compile without perfect syntax. This might drive you crazy at first because it is very natural to forget syntax, but as you program more you will to learn to be assiduous with coding grammar.

So lets get our hands dirty and introduce some sytax.

The semi-colon ;

A semi colon needs to follow every statement we write in Arduino. For example

int LEDpin = 9;

In this statement, I am assigning a value to an integer variable (we will cover this later), notice at the end, the semi-colon. This lets the compiler know that you have finished a chunk of code and are moving on to the next piece.

The double back slash for single line comments //

// When you type these all the text that follows on the same line will be greyed out

Comments are what you use to annotate your code. Good code is commented well. Comments are meant to inform you and anyone else who might stumble across your code, what the heck you were thinking when you wrote it. A good comment would be something like this...

//This is the pin on the Arduino that the LED is plugged into

int LEDpin = 9;

Now, in 3 months when I review this program, I know where to stick my LED.

Comments will be ignored by the compiler - so you can write whatever you like in them. If you have a lot you need to explain, you can also use a multi-line comment which looks like this...

/* The multi-line comment opens with a single backslash followed by an asterisk. Everything that follows is grayed out and will be ignored by the compiler, until you close the comment using first an asterisk and then a backslash like so */

Curly Braces { }

The curly braces are used to enclose information for certain functions. There is always an opening curly bracket and a closing curly bracket. If you forget to close a curly bracket, your complier will not like it and throw an error code.


Lets switch gears a bit and talk about functions.

Functions are pieces of code that are used so often, that they are encapsulated in certain keywords, so that you can use them more easily.

For example, a function could be the following set of instructions...

*Read More...*
*Click Below to Read About This Topic on Our Website*

*About Us:*
This Arduino tutorial was created by Open Source Hardware Group. We are an education company who seek to help people learn about electronics and programming through the ubiquitous Arduino development board.
Customize Your Hybrid Embed Video Player!

6-digit hexadecimal color code without # symbol.


Report video function is under development.


Loading related videos...