skip to content

2.6 Introduction to different syntax for writing any code in Arduino IDE.

1. Sketch:

The Arduino program is called a sketch. It contains the instructions to be performed by the different boards, which are written in Embedded C.

2. Comments :

Comments are the lines that are used to notify the programmer of that particular code snippet. These lines don’t run with code, they are just to explain the particular line used in coding. There are two types of comment

1)  Single line Comment: – single-line comment is written using ‘//’, and does not need a termination.

2) Multi-line Comment: -multi-line comments start with ‘/*’ and end with ‘*/’.

3. Semicolon :

A semicolon is a most important syntactic rule, it is put at the end of every statement  ‘;’.If we don’t use or forget to put a semicolon, an error statement shows.

4. Curly braces :

Curly braces or brackets are an important part of C and C++ programming languages. An open curly brace { must be followed by a closing curly brace }. It is said to be balanced.

5. Setup: void setup() :

This is a declaration for a function called “setup”. This exact line is required in every Arduino sketch. It will only run once when the Arduino is powered or tends to reset.

6. Loop: void loop() { } :

This is where the bulk of your Arduino sketch is executed. The program starts directly after the opening curly bracket ({), runs until it sees the closing curly bracket (}), and jumps back up to the first line in the loop() and starts all over. The loop() function will run over and over and over until the Arduino is reset.

7. Pin mode :

It is used to configure the specified pin to behave as an input or as an output, the pin mode is written in the setup function so, it’s run once while the program executes.

Syntax: – pinMode (LED, OUTPUT);

8. Digital write: 

Digital Write is used to provide the Digital value (HIGH as 5V or LOW as 0V), for those pins which are configured as an OUTPUT with pinMode ().

Syntax: – dgitalWrite (pin, value);

9. Digital Read:

Digital Read is used to read the value (Either HIGH or LOW), for the specified digital pin.

  Syntax: – digitalRead (pin);