Page 109 - ARM Based Microcontroller Projects Using MBED
P. 109

7.7 PROJECT 4—ROTATING LEDs                       95




























            FIG. 7.27  The project constructed on a breadboard.



                         BEGIN
                               Configure used PORT A pins as outputs
                               DO FOREVER
                                           Turn ON LSB LED
                                           Wait 1 second
                                           Turn ON next higher LEDs until MSB LED
                               ENDDO
                         END
            FIG. 7.28  PDL of the project.

            PORT C pins PC_0 to PC_7 as digital outputs. A while statement is used to create an indefinite
            loop. Inside this loop a for statement is used to loop 8 times. The loop counter (variable k)is
            sent to PORT A to turn LEDs ON and OFF as required. One second delay is used between each
            output.


            7.7.8 Modified Program

              The program given in Fig. 7.29 can be written using the PortOut statement. This statement
            groups the bits of the given port. The first parameter of this statement is the port name, while
            the second parameter when set to 1 specifies which bits of the port will be used. In the
   104   105   106   107   108   109   110   111   112   113   114