ENE 207 Lecture 5

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

ENE 207

Fundamentals of Microcontroller

Dr. Bassam A. Hemad


Electrical Power and Machines Dept.
Suez University

1
Variables

2
Using Floating-Point Numbers

Floating-point numbers are used for values expressed with


decimal points.

3
Using Floating-Point Numbers

4
Using Floating-Point Numbers

5
Arrays- Working with Groups of Values

6
Arrays- Working with Groups of Values

7
String

8
String

C-style character arrays

Arduino Strings

9
String

10
String

11
C-Character Strings

You declare strings like this:

Use strlen (short for string length)

Use strcpy (short for string copy)

Use strncpy (like strcpy, but with a limit)


12
Converting a Number to a String

13
Functional Blocks
Functions are used to organize the actions performed by your
sketch into functional blocks.

14
Functional Blocks

15
Functional Blocks

16
Functional Blocks

17
Returning More than One Value from a
Function

18
Returning More than One Value from a
Function

19
Taking Actions Based on Conditions

20
Taking Actions Based on Conditions

21
Repeating a Sequence of Statements

22
Repeating a Sequence of Statements

The do...while loop is similar to the while loop, but the instructions in
the code block are executed before the condition is checked. Use this
form when you must have the code executed at least once,

23
Repeating a Sequence of Statements

break out of a loop in response to some other condition

24
Breaking Out of Loops

Suppose, you want to


terminate a loop early
based on some condition
you are testing.

25
Taking a Variety of Actions Based on a
Single Variable

26
Comparing Character and Numeric
Values

27
Performing Logical Comparisons

28
Performing Bitwise Operations

29
Combining Operations and Assignment

30

You might also like