Arduino: Session3 (Week1) .
Arduino: Session3 (Week1) .
Robotics
About Me
Mohamed Hamed :
►Computers and control systems
department.
► Arduino subteam.
Hackathon
7.0 ►
Arduino
Session 3
Mansoura Robotics
► agenda
① Mapping and potentiometer.
⇛ LAB
② looping. 1
⇛ LAB
③ 7_Segment Displays. 2
⇛ LAB
3
④ Functions.
⇛ Mapping
Mappin
◐ Mapping
g ℃ ℉
0℃ ( 0 ℃ X 1.8 ) + 32 ℉
20 ℃ ( 20 ℃ X 1.8 ) + 32 ℉
80 ℃ ( 80 ℃ X 1.8 ) + 32 ℉
℃ ℉
0℃ 32 ℉ ℉ map (℃ , 0 , 100 , 32 ,
100 ℃ 212 212 ) ;
℉ ℃
Divisions
⇛ potentiometer
VCC
GND
Signal
Potentiometer
Condition
decrement
x--;
Looping
Looping
Looping
Looping
}
▶ LAB 2
Lab (2)
Lab (2)
⇛ 7_Segment
Displays.
7-Segment
7-Segment common Cathode
7-Segment common ANODE
7-Segment
7-Segment
7-Segment
7-Segment
7-Segment
7-Segment
▶ LAB 3
Lab (3)
⇛ Functions
Functions
• A program segment that carries out some specific, well-
defined task
Example
A function to add two numbers
A function to find the largest of n numbers
• A function will carry out its intended task whenever it is
called or invoked
Can be called multiple times
FUNCTIONS
Why
Functions?
• Allows one to develop a program in a modular
fashion
• Divide-and-conquer approach
• Construct a program from small pieces or
components
• Use existing functions as building blocks for new
programs
• Abstraction: hide internal details (library functions)
39
FUNCTIONS
⇛ Defining a Function
A function definition has two parts:
The first line, called header
The body of the function
return-value-type function-name ( parameter-list )
{
declarations and statements
}
40
FUNCTIONS
41
Calling function (Caller)
Called function (Callee) parameter
Parameter passed
43
FUNCTIONS
⇛ Example 2
44
⇛ Next Session :
⇛ Motors
Thank you