The programming language used for the Arduino is based primarily on the C language. Some features of the C++ language may be used in more advanced programming features but are not used in this introduction.
Each program must include two parts for it to be valid, the setup and loop functions. Any statements included in a setup function are only run once by the program. Any statements in the loop function are executed over and over.
/*--- Minimum Arduino programming functions, setup and loop ---*/
void setup()
{
}
void loop()
{
}
The first line in the above program is a comment. The comment is not really required but are helpful in explaining what a program is supposed to do.
/*— Minimum Arduino programming statements —*/
Comments can have two forms. The previous comment starts with the /* characters and continues until the ending characters */ are found.
/* This style of
comment can
cross multiple lines
*/
The other comment form is with the double slash characters
// This is a comment too but is only on a single line in the program.
Comments with the // characters can begin anywhere on a line and are often used following a programming statement.
Verify and Compile
Using the Sketch → Verify/Compile command to check your work.
If everything compiles successfully the Arduino’ programming environment shows the message “Done compiling”. When the sketch compiles without errors it also shows the message stating the Binary sketch size.
This simple program will compile properly but doesn’t do anything useful. It just shows the bare minimum needed to create a program.
(c) 2009 – Vince Thompson
Tags: Arduino, programming, Source code


June 4, 2009 at 8:11 pm |
[...] described in the related article “Introduction to Programming the Arduino“, the programming language used for the Arduino is based primarily on the C [...]
June 5, 2009 at 3:55 pm |
[...] article “Introduction to Programming the Arduino” describes the comment styles used by C programs. The error on line 1 is caused by mixing the [...]