In: Computer Science
FOR an mbed LPC 1768
have 4 LEDs flash 5 times in turn (i.e., LED1 flashes 5 times, followed by LED2, then followed by LED3, and finally followed by LED4, and it repeats). Design the hardware connection of your LEDs to mbed. Build your circuit and include all the required information about your hardware design in your lab report.
Create a new program to fulfill the function of the blinking LEDs as described in last step.
I need the C++ code plz!
Please go through code and comment. I can not display hardware.
CODE:
#include "lpc17xx.h"
#define LED1 25 // led1
#define LED2 26 // led2
#define LED3 27 // led3
#define LED4 28 // led4
int main (void)
{      
   uint32_t i,j,k;  
   uint32 array[4] = {LED1, LED2, LED3, LED4};
   SystemInit();
   LPC_GPIO1->FIODIR |= 1 << LED1;  
        // P1.25 = Outputs
   LPC_GPIO1->FIOCLR = 1 << LED1;  
        // LED OFF
  
   LPC_GPIO1->FIODIR |= 1 << LED2;  
        // P1.26 = Outputs
   LPC_GPIO1->FIOCLR = 1 << LED2;  
        // LED OFF
  
   LPC_GPIO1->FIODIR |= 1 << LED3;  
        // P1.27 = Outputs
   LPC_GPIO1->FIOCLR = 1 << LED3;  
        // LED OFF
  
   LPC_GPIO1->FIODIR |= 1 << LED4;  
        // P1.28 = Outputs
   LPC_GPIO1->FIOCLR = 1 << LED4;  
        // LED OFF
   while(1)
   {
       for(i=0; i<4; i++) // led change
one by one
       {
           for(j =0;
j<5; j++) // led blink 5 times
           {
          
    LPC_GPIO1->FIOSET = 1 <<
array[i];       // LED ON
          
    for(k = 10000000; k > 0; k--); // Delay for
arond 1 seconds
          
    LPC_GPIO1->FIOCLR = 1 <<
array[i];   // LED OFF
          
    for(j = 10000000; j > 0; j--); // Delay for
arond 1 seconds
           }
       }
   }
}