Academic Program

Modify main.c

Modify main.c

Double click on the main.c file. It opens in the editor window.

main.c file

We need to add the following code to the main.c file.

void main(void)
{ // initialize the device SYSTEM_Initialize();
 
while (1)
{
                   // Add your application code
                  if (switch_GetValue() == 0)
                 {
                 led_SetHigh();
                 }
        else
                {
               led_SetLow();
               }
    }
 }
 

MCC automatically generates switch_GetValue(), led_SetHigh() and, led_SetLow(). You can find them in the pin_manager header file.

Next, click on the Build Main Project icon Build Main Project icon to compile the code. You will see a BUILD SUCCESSFUL message in the output window.

Build project