Upload
abdelrahman-elewah
View
115
Download
3
Embed Size (px)
Citation preview
Digital Signal
Processors
General-purpose Microprocessors Microcontrollers
Microprocessors
8086, Pentium I-IV, Core-duo, Atom, Sparc,..
8051, PIC, ATMEGA, AVR,.. TMS320XX
AD21XX,…
Type of Microprocessors
WHAT IS ARDUINO?
Why invented the Arduino boards ?
Arduino shield
GSM shield Arduino
GPS shield Arduino
Programming
Sketches
??
? ?
? ??
??
?
Microcontroller
Arduino c
C programming
Important notes { } curly braces
Curly braces (also referred to as just "braces" or "curly brackets") define the beginning and end of
function blocks and statement blocks such as the void loop() function and the for and if statements.
Void Loop(){ Statements;}
; semicolon A semicolon must be used to end a statement and separate
elements of the program. A semicolon is also used to separate elements in a for loop.
int x = 13; // declares variable 'x' as the integer 13
/*… */ block comments Block comments, or multi-line comments, are areas of text ignored
by the program and are used for large text descriptions of code or comments that help others understand parts of the program. They begin with /* and end with */ and can span multiple lines.
/* this is an enclosed block comment don’t forget the closing comment - they have to be balanced! */
// line comments Single line comments begin with // and end with the next
line of code. Like block comments, they are ignored by the program and take no memory
space.
// this is a single line comment
Single line comments are often used after a valid statement to provide more information about what the statement
accomplishes or to provide a future reminder.
boolean (0, 1, false, true) char (e.g. ‘a’ -128 to 127) unsigned char (0 to 255)
byte (0 to 255) int (-32,768 to 32,767) unsigned int (0 to 65535)
word (0 to 65535) long (-2,147,483,648 to 2,147,483,648
unsigned long (0 to 4,294,967,295)
float -(3.4028235E+38 to
3.4028235E+38)double (currently same
as float)sizeof(myint) // returns 2
bytes
General Operators= (assignment operator)
+ (addition) - (subtraction)
(multiplication) */ (division)% (modulo)
== (equal to) != (not equal to)< (less than) > (greater than)
<= (less than or equal to)>= (greater than or equal to)
&& (and) || (or) ! (not)
x ++ // same as x = x + 1, or increments x by +1
x -- // same as x = x - 1, or decrements x by -1
x += y // same as x = x + y, or increments x by +y
x -= y // same as x = x - y, or decrements x by -y
x *= y // same as x = x * y, or multiplies x by y
x /= y // same as x = x / y, or divides x by y
Arduino c
C programming
Arduino c
C programming
Lecture 2
Microcontroller
Arduino c
C programming
Important notes { } curly braces
Define the beginning and end of function blocks and statement blocks such as the void loop() function and the for and if statements.
Void Loop(){ Statement;Statement;
}
; semicolon A semicolon must be used to end a statement and separate
elements of the program. A semicolon is also used to separate elements in a for loop.
int x = 13; // declares variable 'x' as the integer 13
/*… */ block comments Block comments, or multi-line comments, are areas of text ignored
by the program and are used for large text descriptions of code or comments that help others understand parts of the program. They begin with /* and end with */ and can span multiple lines.
/* this is an enclosed block comment don’t forget the closing comment - they have to be balanced! */
// line comments Single line comments begin with // and end with the next
line of code. Like block comments, they are ignored by the program and take no memory
space.
// this is a single line comment
Single line comments are often used after a valid statement to provide more information about what the statement
accomplishes or to provide a future reminder.
boolean (0, 1, false, true) char (e.g. ‘a’ -128 to 127) unsigned char (0 to 255)
byte (0 to 255) int (-32,768 to 32,767) unsigned int (0 to 65535)
word (0 to 65535) long (-2,147,483,648 to 2,147,483,648
unsigned long (0 to 4,294,967,295)
float -(3.4028235E+38 to
3.4028235E+38)double (currently same
as float)sizeof(myint) // returns 2
bytes
General Operators= (assignment operator)
+ (addition) - (subtraction)
(multiplication) */ (division)% (modulo)
== (equal to) != (not equal to)< (less than) > (greater than)
<= (less than or equal to)>= (greater than or equal to)
&& (and) || (or) ! (not)
Code Structures
Control statements • If statement • Switch case statement • While statement • Do …. While statement • For statement
• If statement • Switch case statement
• While statement • Do …. While statement • For statement
If statement One way selection
Example
If (score >= 60) grade = ‘P’ ;else grade = ‘F’ ;
Example
Two way selection
Multiple selections
Example
Important notes { } curly braces
Define the beginning and end of function blocks and statement blocks such as the void loop() function and the for and if statements.
Void Loop(){ Statement;Statement;
}
Compound statement (block of statements):
if (age > 18){
cout << "Eligible to vote." << endl;cout << "No longer a minor." << endl;
} else{
cout << "Not eligible to vote." << endl;cout << "Still a minor." << endl;
}
Example
Switch case statement switch structure
Example
• If statement • Switch case statement
• While statement • Do …. While statement • For statement
Example
• while Looping (Repetition) • do…while Looping (Repetition) Structure (continued)
Example
For statement
Infinite loop using while and for
for (;;)cout << "Hello" << endl;
While(1){cout << "Hello" << endl;}
Arduino c
C programming
Arduino c
C programming