0% found this document useful (0 votes)
13 views

3scope & Operators in Arduino

Uploaded by

Muntasir Sunny
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

3scope & Operators in Arduino

Uploaded by

Muntasir Sunny
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Scope & Operators in

Arduino
CSE- 315
Peripherals & Interfacing
Abdullah Al Omar
Lecturer, CSE, UAP
Scope
There are three types of scope in Arduino environment.
• Global Scope
• Formal Scope
• Local Scope
Global Scope: Global scope occurs when a variable is defined “outside of a function”.
1. the global scope is the scope that contains, and is visible in, all other scopes.
2. A variable with global scope has a lifetime that exists from the time the
program is loaded until the program terminates

Int T , S ;
float c = 0 ; Global variable declaration
void setup () {
//13 no. pin declaration
}
void loop(){
//13 no. pin ON/1
//13 no. pin OFF/0
}
Formal Scope:
Suppose int A() is a function:
int A( int x, int y){
int result;
result = x * y;
return result;
}

void setup(){
serial.begin(9600);
}
void loop() { Formal scope variable:
int i = 2;
int j = 3;
int k;
k = A(i, j); // k now contains 6
Serial.println(k);
delay(500);
}
Local Scope:
• The variable which resides in the function only. So the variable can only be
used in the function.
• These variables are not valid in outside of the function.
Void loop () {
int x , y ;
int z ; //Local variable declaration
x = 0;
y = 0; // initialization
z = 10;
}
Class Work (You have 10 minutes to complete the
task`)
Q1. Declare a variable containing your registration id, so that we can
use it in any block (any function). Assign it to the variable named
‘dhaka’ in the void loop function and pass it to a function to add 1 with
it. The function will return the value to the loop function.

P.S. Write it on the computer/hard copy.


Operators
There are five types of operator in Arduino:
1. Arithmetic Operator
2. Comparison Operator
3. Boolean Operator
4. Bitwise Operator
5. Compound Operator
Hand Notes

Pdf will be provided.


• Resource Link- https://www.arduino.cc/reference/en/
Thank you

You might also like