Arduino Coding

From Network Security Wiki


Data Types

Void
  • The void keyword is used only in function declarations.
  • It indicates that the function is expected to return no information to the function from which it was called.
Void Loop ( ) {
   // rest of the code
}
Boolean
  • Boolean holds one of two values, true or false.
  • Each Boolean variable occupies one byte of memory.
boolean val = false;
boolean state = true;


Char
  • A data type that takes up one byte of memory that stores a character value.
  • Character literals are written in single quotes like: 'A'
  • For multiple characters, strings use double quotes: "ABC".
  • However, characters are stored as numbers.
  • You can see the specific encoding in the ASCII chart.
  • This means that it is possible to do arithmetic operations on characters, in which the ASCII value of the character is used.
  • For example, 'A' + 1 has the value 66, since the ASCII value of the capital letter A is 65.
Char chr_a = ‘a’ ;//declaration of variable with type char and initialize it with character a
Char chr_c = 97 ;//declaration of variable with type char and initialize it with character 97
Unsigned char
Byte
Int
Unsigned int
Word
Long
Unsigned long
Short
Float
Double
Array
String-char array
String-object

Variables & Constants

        This section is under construction.

Operators

        This section is under construction.

Control Statements

If Statements

Form 1
if (expression)
   statement;
Form 2

You can use the if statement without braces { } if you have one statement.

if (expression) {
   Block of statements;
}

If Else Statement

if (expression) {
   Block of statements;
}
else {
   Block of statements;
}

If Else-If Else Statements

if (expression_1) {
   Block of statements;
}

else if(expression_2) {
   Block of statements;
}
.
.
.

else {
   Block of statements;
}

Switch Case Statement

switch (variable) { 
   case label:
   // statements
   break;
}

case label: { 
   // statements
   break;
}

default: { 
   // statements
   break;
}

Loops

        This section is under construction.

Functions

        This section is under construction.

Strings

        This section is under construction.

String Objects

        This section is under construction.


References





{{#widget:DISQUS |id=networkm |uniqid=Arduino Coding |url=https://aman.awiki.org/wiki/Arduino_Coding }}