Introduction To Arduino
Introduction To Arduino
Introduction to...
Arduino
Contents:
Introduction [20 min]:
1. What is Micro-Controller?
2. What is Arduino?
3. Types of Arduino.
4. Arduino UNO board.
5. Sensors:
- Digital, Analog sensors.
- Light sensors [IR sensor, Photo-Resistor].
Coding structure and examples [30 min]:
1. Data types and operators.
2. What is “Function”?
3. Control statements [if, if… else, switch case.].
4. Loop statements[while, for, do… while.].
5. Common functions.
Workshop[20 min] DC motor control:
Introduction
It is a micro-computer. As any
computer it has internal CPU, RAM,
IOs interface.
It is used for control purposes, and
for data analysis.
Famous microcontroller
manufacturers are MicroChip,
Atmel, Intel, Analog devices, and
more.
What is Arduino?
Atmel
MicroController
USB port
Power input
Analog input.
Power Supply
Digital or Analog?
• All physical quantities are analog.
• Analog means that the quantity can take any value
between its
• minimum value and maximum value.
• Digital means that the quantity can take specific levels of
Digital and analog.
• Ex: 1- Digital:
• English alpha consists of 26 letter, there is no letter
between A
• and B.
• - Square waves are Digital.
• Ex.: 2- Analog:
• Temperature, can take any value[-1,12.8,25.002,… etc.].
• - Sine waves are analog.
Sensors:
A device that transforms the physical quantity into electrical
value.
Ex.: Light sensor transduce the light into change in voltage or
resistance.
Sensors
Arduino Coding.
You may need to know about these typed: Array, Boolean, byte, etc. here.
Statement and operators:
Statement represents a command, it ends with ;
Ex:
int x;
x=13;
Operators are symbols that used to indicate a specific
function:
- Math operators: [+,-,*,/,%,^]
- Logic operators: [==, !=, &&, ||]
-Comparison operators: [==, >, <, !=, <=, >=]
Syntax:
; Semicolon, {} curly braces, //single line
comment, /*Multi-line comments*/
Statement and operators:
Compound Operators:
++ (increment)
-- (decrement)
+= (compound addition)
-= (compound subtraction)
*= (compound multiplication)
/= (compound division)
Control statements:
If Conditioning:
if(condition)
{
statements-1;
…
Statement-N;
}
else if(condition2)
{
Statements;
}
Else{statements;}
Control statements:
Switch case:
switch (var) {
case 1:
//do something when var equals 1
break;
case 2:
//do something when var equals 2
break;
default:
// if nothing else matches, do the default
// default is optional
}
Loop statements:
Do… while:
do
{
Statements;
}
while(condition); // the statements are run at least once.
While:
While(condition)
{statements;}
for
for (int i=0; i <= val; i++){
statements;
}