Download Manual ARM Microcontroller Course E.T.S.V. Scintilla
Transcript
haveBreakfast();
//then continue with the next step of your morning
routine
case 1:
//leave directly if there is only on 1 quarter of an
hour left
leaveForLecture();
//and end your morning routine (jump out of switch
statement)
break();
default:
//in the case that the time until the lecture is more than 4 quarters
of an hour or less than 1 (0 or negative), go back to sleep.
goBackToSleep();
//end of the default routine
break;
}
4.3.2
Iteration Statements
C knows two types of iterations: for loops and while loops. It is assumed that
the reader knows how to work with these loops. The syntax for these loops is
given in code snippet 10 and code snippet 11.
Snippet 10 Example of a for loop
//perform a piece of code 10 times
for(uint16_t i=0; i<10; i++){
//write the code to loop here
}
Snippet 11 Example of a while loop
//blink an LED as long as a button is pushed
while(readButton()){
blinkLED();
}
19