Implement the design on Explorer 16 as Project 1. LED D10 will be used as the RUN LED indicator.

Write an application (in C) which does the following:
1. Make the RUN LED(D10) toggle at every 3.5 Seconds (exact) interval using one of the Timer (Timer 1) module of the Microcontroller.
2. The Knight Rider pattern now consists of 7 LEDs (D9-D3). If the switch (S3) is open, the pattern is from Left to Right direction. If the switch (S3) is closed, the pattern is from Right to Left direction.
3. Repeat the whole process in an infinite way.

To implement the design on Explorer 16 as Project 1, and write an application in C that meets the given requirements, you can follow these steps:

Step 1: Setup the Microcontroller and Peripherals
- Make sure you have MPLAB X IDE and XC16 Compiler installed on your computer.
- Connect the Explorer 16 development board to your computer via a USB cable.
- Install the necessary device drivers for the development board if required.

Step 2: Create a New Project in MPLAB X IDE
- Open MPLAB X IDE and create a new project by navigating to File -> New Project.
- Select "Microchip Embedded" as the category, "Standalone Project" as the project type, and choose the appropriate device for your Explorer 16 board.
- Specify a project name and choose a location to save the project files.
- Click "Finish" to create the project.

Step 3: Configure the RUN LED
- In the project tree, expand "Header Files" and open the "xc.h" file.
- Locate the section where peripherals and registers are defined.
- Find the definition for LED D10 and note the corresponding port and pin.
- Use this port and pin information in the application code to control the LED.

Step 4: Configure Timer 1 for LED Toggle
- In the project tree, expand "Source Files" and open the main.c file.
- Include the necessary header files at the top of the file (e.g., #include <xc.h>).
- Set up Timer 1 to generate an interrupt every 3.5 seconds.
- Configure the interrupt service routine (ISR) for Timer 1, where you toggle the state of the RUN LED.

Step 5: Configure Knight Rider LEDs
- Use the port and pin information for LEDs D3-D9 to control the Knight Rider pattern.
- Determine the direction of the pattern based on the state of switch S3.
- If S3 is open, the pattern should move from left to right. If S3 is closed, the pattern should move from right to left.
- Write the necessary logic in the main function to control the Knight Rider pattern.

Step 6: Run the Code
- Build the project by selecting "Build Project" from the main toolbar or by pressing Ctrl + Shift + B.
- Connect the Explorer 16 board to a suitable power source.
- Upload the compiled code to the microcontroller by selecting "Make and Program Device" from the main toolbar or by pressing Ctrl + Shift + F5.
- Monitor the behavior of the RUN LED and Knight Rider pattern.
- The code should continuously run the specified tasks in an infinite loop.

By following these steps, you should be able to implement the design on Explorer 16 as Project 1 and write the application in C according to the given requirements.

Here is a possible implementation of the described application in C:

```c
#include <xc.h>

// Configuration bits
#pragma config FNOSC = PRIPLL // Oscillator Selection bits (Primary Osc with PLL)
#pragma config POSCMOD = HS // Primary Oscillator Configuration bits (HS oscillator mode)
#pragma config FPLLIDIV = DIV_2 // PLL Input Divider (2x Divider)
#pragma config FPLLMUL = MUL_16 // PLL Multiplier (16x Multiplier)
#pragma config FPLLODIV = DIV_1 // PLL Output Divider (PLL Divide by 1)
#pragma config FPBDIV = DIV_2 // Peripheral Clock divisor (Pb_Clk is Sys_Clk/2)
#pragma config FWDTEN = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config FSOSCEN = OFF // Secondary Oscillator Enable (Disabled)

// Function prototypes
void timer1Delay(float seconds);
void toggleLed(void);
void knightRiderPattern(int direction);

// Constants
#define LED_RUN LATBbits.LATB10
#define LED_KNIGHT_LEFT LATBbits.LATB9
#define LED_KNIGHT_RIGHT LATBbits.LATB3
#define SWITCH_S3 PORTGbits.RG6

int main(void) {
// Initialize LEDs as output
TRISBbits.TRISB10 = 0; // LED_RUN
TRISBbits.TRISB9 = 0; // LED_KNIGHT_LEFT
TRISBbits.TRISB3 = 0; // LED_KNIGHT_RIGHT

// Initialize switch as input
TRISGbits.TRISG6 = 1; // SWITCH_S3

while (1) {
// Toggle LED_RUN every 3.5 seconds
toggleLed();
timer1Delay(3.5);

// Check switch state and update knight rider pattern accordingly
if (SWITCH_S3 == 0) { // Switch open, left to right direction
knightRiderPattern(1);
} else { // Switch closed, right to left direction
knightRiderPattern(-1);
}
}

return 0;
}

// Delay function using Timer 1
void timer1Delay(float seconds) {
TMR1 = 0;
PR1 = (int)(seconds / (1.0/8000000.0) + 0.5); // Calculate the period based on desired delay

// Configure Timer 1 settings
T1CONbits.TCS = 0; // Internal clock source
T1CONbits.TCKPS = 0b00; // Prescaler 1:1
T1CONbits.TON = 1; // Enable Timer 1

// Wait until the Timer 1 interrupt flag is set
while (!IFS0bits.T1IF);

// Clear the Timer 1 interrupt flag
IFS0bits.T1IF = 0;
}

// Toggle LED_RUN state
void toggleLed() {
LED_RUN = !LED_RUN;
}

// Knight rider pattern function
void knightRiderPattern(int direction) {
// Calculate next LED position based on direction
static int position = 0; // Start from first LED
position += direction;

// Check if position exceeds LED range
if (position < 0) {
position = 1; // Skip LED_KNIGHT_RIGHT
} else if (position > 6) {
position = 5; // Skip LED_KNIGHT_LEFT
}

// Update LED states accordingly
LED_KNIGHT_LEFT = (position >= 3) ? 1 : 0;
LED_KNIGHT_RIGHT = (position <= 3) ? 1 : 0;
}
```

This code uses Timer 1 to implement the delay for toggling the RUN LED every 3.5 seconds. It also reads the state of switch S3 to determine the direction of the knight rider pattern. The pattern starts from left to right if the switch is open, and from right to left if the switch is closed.

Note that this implementation assumes that the necessary peripheral library and configuration bits are set correctly for the specific microcontroller being used. Also, the code assumes that the LEDs and the switch are connected to the specified port pins on the Explorer 16 board. Please review the board's documentation and adjust the port pin assignments if needed.

To implement the design on Explorer 16 as Project 1, follow these step-by-step instructions:

Step 1: Set up the necessary hardware
- Connect LED D10 to the desired output pin of the microcontroller.
- Connect LEDs D9-D3 to their respective output pins on the microcontroller.
- Connect switch S3 to an input pin on the microcontroller.

Step 2: Initialize the microcontroller and configure necessary modules
- Include the necessary header files for the microcontroller being used.
- Configure Timer 1 module to generate an interrupt every 3.5 seconds.
- Configure the input pin for switch S3.

Step 3: Define necessary variables and constants
- Define a variable to keep track of the LED pattern direction (left to right or right to left).
- Define constants for the output pins of LEDs D9-D3 and switch S3.

Step 4: Set up the main function
- Within the main function, configure Timer 1 to generate an interrupt every 3.5 seconds.
- Enable global interrupts.

Step 5: Implement the interrupt service routine for Timer 1
- Toggle the state of LED D10.

Step 6: Implement the main application logic
- Check the state of switch S3.
- If S3 is open, initialize the LED pattern from left to right.
- If S3 is closed, initialize the LED pattern from right to left.
- Use a loop to repeat the LED pattern.
- Within the loop, shift the LED pattern one position to the left or right based on the switch state.
- Use delay functions to control the speed of the LED pattern movement.

Step 7: Repeat the whole process infinitely
- Use an infinite loop to continuously repeat the LED pattern and toggle of LED D10.

Here's a sample code implementation in C that incorporates the steps mentioned above:

```c
#include <xc.h> // Include the necessary header files for the microcontroller being used

#define LED_RUN LATBbits.LATB10 // Define the output pin for LED D10 (RUN LED)
#define LED_PATTERN LATBbits.LATB7 // Define the output pin for the first LED in the pattern (D9)
#define SWITCH_DIRECTION PORTBbits.RB3 // Define the input pin for switch S3

// Initialize the microcontroller and configure necessary modules
void initialize() {
// Configure Timer 1 to generate an interrupt every 3.5 seconds
// ...

// Configure switch S3 as input
TRISBbits.TRISB3 = 1; // Set RB3 as input
CNPUBbits.CNPUB3 = 1; // Enable weak pull-up on RB3
}

void __interrupt() ISR() {
// Check for Timer 1 interrupt and toggle the state of LED D10
if (TMR1IF) {
LED_RUN = !LED_RUN; // Toggle the RUN LED
TMR1IF = 0; // Clear the Timer 1 interrupt flag
}
}

void main() {
initialize(); // Initialize the microcontroller

// Enable global interrupts
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;

while (1) {
// Check the state of switch S3
if (SWITCH_DIRECTION) {
// If S3 is open, initialize the LED pattern from left to right
LED_PATTERN = 0b0000001; // Set LED D9 high, all others low
} else {
// If S3 is closed, initialize the LED pattern from right to left
LED_PATTERN = 0b1000000; // Set LED D3 high, all others low
}

// Use a loop to repeat the LED pattern
while (1) {
// Shift the LED pattern one position to the left or right based on the switch state
if (SWITCH_DIRECTION) {
// Shift pattern from left to right
LED_PATTERN = (LED_PATTERN << 1) | (LED_PATTERN >> 6);
} else {
// Shift pattern from right to left
LED_PATTERN = (LED_PATTERN >> 1) | (LED_PATTERN << 6);
}

__delay_ms(350); // Delay 350 milliseconds (3.5 seconds interval)
}
}
}
```

Please note that this code assumes you are using a Microchip PIC microcontroller with the XC8 compiler. You may need to make some modifications if you are using a different microcontroller or compiler.