Getting Started

(lily) #1

Chapter 5: C Control Flow....................................................................................


k open
e kimono and take a good hard look.

e
e followed by a semicolon:

PORTD = ~i;

tes the statement.

Compound st oup of statements or
declarations in ock iler to


00 wait count was too long so I changed it to 2200:

while(QuarterSecondCount < 2200)//17600);
Quarte


ut I wanted to leave the 17600 in case I ever needed it again, so I commented it

QuarterSecondCount = 0;

Chapter 5: C Control Flow


We specify the order in which computations are performed with control
statements. We’ve already peeked at some of these concepts, now Let’s jer
th


Statements and Blocks


Expressions such as PORTD = ~i or _delay_loop_2(30000) or i -= 128 becom
statements when they ar


_delay_loop_2(30000);
i -= 128;

The semicolon termina


ate
bl

ments are made by enclosing a gr
delimited by braces ‘{‘ and ‘}’. This causes the comp
handle the block as a unit.


Tale of a bug:
I wrote the following statement:


while(QuarterSecondCount < 17600);
QuarterSecondCount = 0;


Then decided that the 176


rSecondCount = 0;

B
out. Do you see a problem here?


Well, what I meant to say was:


while(QuarterSecondCount < 2200);

Free download pdf