Basics Of Arduino coding
Hello friends,
In this section we are learn about basic fundamentals of coding in arduino , for this session if you have some basic knowledge of coding in C or any other language that.s good but if you dont have any knowledge about coding so dont worry you still can learn it is so easy and We will cover all the concepts.
DATA TYPES
Integer:
It is variable. It is used when the value is between-2147483648to -2147483647
Character:
It is used when assign a single character. Its value is in a range between -127 to 128
Float :
number can be large as 3.4028235E+38 and as low as -3.4028235E to -3.4028235E+38.
Long :
It can extended size variable for number storage and store 32 bits(4 Bytes).Its range is in between -2147483 to 2147483.
CODE STRUCTURE
Void setup(){
indicate initial valule system on starting
indicate initial valule system on starting
}
Void setup{
frequently run statements after startup
}
INPUT/OUTPUT
Pinmode:
PinMode(pin no., OUTPUT);
PinMode(pin no. ,INPUT);
Digitalread:
digitalRead(pin no.,value(high/low));
Digitalwrite:
digitalWrite(pin no., value(high/low));
Analogread:
analogRead(pin no., value);
Analog write:
analogWrite(pin no., value);
STATEMENTS
Statement represents a command and it is terminated(end) with ;
EXP: int x=13; //it is called declaration+ initialization
; semicolon
{} curly braces
//single line comment
/* */ Multi-line Comment
OPERATORS
Arithmetic Operator:
+ : Addition
- : Subtraction
* : Multiplication
/ : Division% : Modulo division
Logic Operator:
== : equal to!= : Not equal to&& : Logical AND|| : Logical OR
Comparison Operator :
== : is equal to!= : Not equal to> : Greater than< : Less than<= : Less than or equal to>= : Greater than or equal to<> : Not equal to in particular value range
Unary Operator :
++ : Increment-- : Decrement+= : Compound Addition-= : Compound Subtraction*= : Compound Multiplication/= : Compound Division
CONTROL STATEMENTS
If Conditioning:
If(condition)
{
statement 1;
}
else if
{
statement 2;
}
else
{
statement;
}
Switch case:
Switch(var)
{
case 1:
Statements;
break;
case 2;
Statements;
break;
default;
}
LOOPS
Do…while:
do
{
Statements;
}
While(condition);
While:
While(condition)
{
Statements;
}
for:
for(i=0(initialization); I<=val(limit); i++(inc/dec))
{
statements;
}
HIGH/ LOW
PinMode(pin no. ,INPUT);PinMode(pin no., OUTPUT);
USER FUNCTIONS
Serial.Begin(9600):
- This function open up with the USB port for special serial communication and also sets the baud rate. The baud is commonly 9600bps.
- i.e. Serial.Begin(9600);
Serial.println(value):
- It prints the value passed into the backets on to the serial monitor.
- When click on serial monitor you get the values.
- i.e. Serial.Println(value);
so friends this is some basic info. for the coding.
Nice
ReplyDeleteThank you soo muchh
DeleteUsefull 🙌
ReplyDeleteThanks a lot
DeleteVery well explained
ReplyDeleteExplanation is awesome
ReplyDelete