Page 28 - ARM Based Microcontroller Projects Using MBED
P. 28
14 2. MICROCONTROLLER-BASED PROJECT DEVELOPMENT CYCLE
FIG. 2.7 Using IF-THEN-ELSE IF-ENDIF.
FIG. 2.8 Using DO-FOREVER-ENDDO statement.
2.2.5 DO-ENDDO
The DO-ENDDO statement is used to create loops (or iterations) in programs. Every Do
statement must be terminated with an ENDDO statement. It is permissible to use conditions
after the DO statement to create conditional loops. An example DO-ENDDO loop is shown in
Fig. 2.9 where the LED is flashed 10 times with 2s delay between each output. Another ex-
ample DO-ENDDO loop is shown in Fig. 2.10.
2.2.6 REPEAT-UNTIL
The REPEAT-UNTIL statement is similar to DO-ENDDO statement but here the condition
to terminate the loop is checked at the end and therefore the loop is executed at least once.
Fig. 2.11 shows an example of REPEAT-UNTIL loop.