# Problem
Create a program that does the following:
1. Turns on LEDs[3:0] while the others are off then waits for half a second.
2. Turns on LEDs[7:4] while the others are off then waits for half a second.
3. Turns on LEDs[11:8] while the others are off then waits for half a second.
4. Turns on LEDs[15:12] while the others are off then waits for half a second.
5. Repeats the above steps forever.
Use a loop with an index variable to do this, don't hard code with multiple lines of code.
# Process
...
# Answer
```c
int main(void)
{
/* Reset all peripherals. Initializes the Flash interface and the SysTick. */
HAL_Init();
/* Configure the system clock. */
SystemClock_Config();
/* Initialize all configured peripherals. */
MX_GPIO_Init();
MX_I2C1_Init();
MX_I2S3_Init();
MX_SPI1_Init();
MX_USB_HOST_Init();
MX_TIM7_Init();
/* Configure GPIOs. */
GPIOD->MODER = 0x55555555;
GPIOC->MODER |= 0x0;
/* Infinite loop. */
while (1)
{
/* Turn on the output LEDs in groups of four. */
for (int i = 0; i <= 12; i += 4)
{
GPIOD->ODR = 0x0;
GPIOD->ODR |= 0xF << i;
HAL_Delay(500);
}
MX_USB_HOST_Process();
}
}
```