LESSON 02 – BASIC
PROGRAM ARDUINO BASIC PROGRAM Here is what an empty
arduino program looks like: void setup() { } void loop() { } COMMANDS In programming, commands
are called statements. We will place these statements inside the
setup() function or inside the loop() function. void setup() { //statements go here } void loop() { //statements go here } INDENTING All statements inside the
setup() or loop() function blocks should be indented by 4 spaces. This allows for each readiblility and is
considered good programming practice. SETUP VS LOOP The setup function is
executed once. So you place statements
in there that you want to run once. The loop function is
executed over and over again. So
statements that need to be repeated over and over need to be placed inside
the loop function. COMMENTS We can add information
that will be completely ignored by the arduino. We do this by starting the line with the
double slash //. Such lines are called comments. Comments are often used to explain some of
the more difficult parts of programs so that readers could understand what
statements are doing. |