Hardware:

Implement the design on Explorer 16 as Project 1. LED D10 will be used as the RUN LED indicator.
Application:
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 above application on the Explorer 16 development board, you will need to consider the following steps:

1. Connect the LED D10 to the appropriate pin of the microcontroller, which controls the RUN LED indicator. Refer to the datasheet or schematic of the development board to identify the correct pin.
2. Configure Timer 1 module of the microcontroller to generate an interrupt at a frequency equivalent to a 3.5-second interval. You will need to set up the timer registers appropriately. Consult the microcontroller's datasheet for detailed information on configuring the timer module.
3. In the interrupt service routine for Timer 1, toggle the state of the RUN LED by writing the appropriate value to the pin controlling LED D10. This can be done by reading the current state of the pin and then writing the opposite state.
4. Connect the LEDs D9-D3 to the microcontroller's pins, taking note of the appropriate direction (left to right or right to left) based on the state of switch S3. Again, refer to the development board's documentation for the pin connections.
5. Write a C program that continuously executes the Knight Rider pattern on the LEDs. Use a loop to iterate through the sequence of lighting up the LEDs in the desired direction. Use conditional statements to determine the direction based on the state of switch S3.
6. To ensure the application repeats the entire process infinitely, place the main functionality of the program inside an infinite loop.

In order to implement these steps, you will need a good understanding of the microcontroller's hardware architecture, peripheral modules, and programming in C. Additionally, it will be helpful to refer to the microcontroller's datasheet and the development board's documentation for specific pin assignments and timer module configuration details.

Here's an example of how you can implement the mentioned hardware design and application using C language on the Explorer 16 board with a Microcontroller:

```c
#include <xc.h>

// Function to configure Timer 1
void configureTimer1() {
T1CONbits.TON = 0; // Disable Timer 1
T1CONbits.TCS = 0; // Select internal clock
T1CONbits.TGATE = 0; // Disable gated timer mode
T1CONbits.TCKPS = 0b11; // Set Timer 1 prescaler to 1:256
TMR1 = 0x00; // Clear Timer 1 register
PR1 = 54799; // Set Timer 1 period value for 3.5 seconds

IFS0bits.T1IF = 0; // Clear Timer 1 interrupt flag
IEC0bits.T1IE = 1; // Enable Timer 1 interrupt
IPC0bits.T1IP = 0x01; // Set Timer 1 interrupt priority
}

// Timer 1 interrupt service routine
void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) {
LATDbits.LATD10 ^= 1; // Toggle RUN LED (D10)
IFS0bits.T1IF = 0; // Clear Timer 1 interrupt flag
}

// Function to configure IO ports and pins
void configureIO() {
// Configure LED pins as outputs
TRISDbits.TRISD10 = 0; // RUN LED (D10)
TRISDbits.TRISD9 = 0; // Knight Rider LED 1 (D9)
TRISDbits.TRISD8 = 0; // Knight Rider LED 2 (D8)
TRISDbits.TRISD7 = 0; // Knight Rider LED 3 (D7)
TRISDbits.TRISD6 = 0; // Knight Rider LED 4 (D6)
TRISDbits.TRISD5 = 0; // Knight Rider LED 5 (D5)
TRISDbits.TRISD4 = 0; // Knight Rider LED 6 (D4)
TRISDbits.TRISD3 = 0; // Knight Rider LED 7 (D3)

// Configure Switch pin as input
TRISFbits.TRISF6 = 1; // Switch (S3)

// Set initial LED states
LATDbits.LATD10 = 1; // RUN LED (D10) off
LATDbits.LATD9 = 0; // Knight Rider LED 1 (D9) off
LATDbits.LATD8 = 0; // Knight Rider LED 2 (D8) off
LATDbits.LATD7 = 0; // Knight Rider LED 3 (D7) off
LATDbits.LATD6 = 0; // Knight Rider LED 4 (D6) off
LATDbits.LATD5 = 0; // Knight Rider LED 5 (D5) off
LATDbits.LATD4 = 0; // Knight Rider LED 6 (D4) off
LATDbits.LATD3 = 0; // Knight Rider LED 7 (D3) off
}

// Function to toggle Knight Rider pattern
void toggleKnightRiderPattern() {
// Check switch state
if (PORTFbits.RF6 == 0) {
// Switch (S3) open, Left to Right direction
LATDbits.LATD3 = !LATDbits.LATD3;
__delay_ms(100);
LATDbits.LATD4 = !LATDbits.LATD4;
__delay_ms(100);
LATDbits.LATD5 = !LATDbits.LATD5;
__delay_ms(100);
LATDbits.LATD6 = !LATDbits.LATD6;
__delay_ms(100);
LATDbits.LATD7 = !LATDbits.LATD7;
__delay_ms(100);
LATDbits.LATD8 = !LATDbits.LATD8;
__delay_ms(100);
LATDbits.LATD9 = !LATDbits.LATD9;
__delay_ms(100);
} else {
// Switch (S3) closed, Right to Left direction
LATDbits.LATD9 = !LATDbits.LATD9;
__delay_ms(100);
LATDbits.LATD8 = !LATDbits.LATD8;
__delay_ms(100);
LATDbits.LATD7 = !LATDbits.LATD7;
__delay_ms(100);
LATDbits.LATD6 = !LATDbits.LATD6;
__delay_ms(100);
LATDbits.LATD5 = !LATDbits.LATD5;
__delay_ms(100);
LATDbits.LATD4 = !LATDbits.LATD4;
__delay_ms(100);
LATDbits.LATD3 = !LATDbits.LATD3;
__delay_ms(100);
}
}

// Main function
int main() {
configureIO(); // Configure IO ports and pins
configureTimer1(); // Configure Timer 1

while (1) {
toggleKnightRiderPattern(); // Toggle Knight Rider pattern

// Delay for 3.5 seconds (exact)
T1CONbits.TON = 1; // Enable Timer 1
while (!IFS0bits.T1IF); // Wait for Timer 1 interrupt
T1CONbits.TON = 0; // Disable Timer 1
IFS0bits.T1IF = 0; // Clear Timer 1 interrupt flag
}

return 0;
}
```

In this code, the `configureTimer1()` function is used to configure Timer 1 to generate interrupts every 3.5 seconds. The Timer 1 interrupt service routine will toggle the RUN LED (D10) every time the interrupt occurs.

The `toggleKnightRiderPattern()` function is responsible for toggling the Knight Rider pattern based on the state of the switch (S3). If the switch is open, the pattern moves from left to right, and if the switch is closed, the pattern moves from right to left.

The `while (1)` loop in the `main()` function repeats the process indefinitely, with a delay of 3.5 seconds between each iteration.

Make sure to include the necessary header files for the microcontroller and configure the oscillator and other settings according to your specific requirements.

Note: This code assumes the use of a specific Microcontroller and its associated registers and pins. If you are using a different Microcontroller, you may need to modify the code accordingly.

To implement the described hardware and application design on the Explorer 16 board, follow these steps:

Hardware Setup:
1. Connect the LED D10 to a suitable GPIO pin on the Explorer 16 board.
2. Connect the LEDs D3-D9 in sequence to the GPIO pins.
3. Connect the switch S3 and configure it as an input to control the pattern direction.

Application Code:

1. Include the necessary header files for the microcontroller and timers:
```c
#include <xc.h>
#include <stdint.h>
#include <stdbool.h>
```

2. Configure the microcontroller's oscillator and other required settings:
```c
#pragma config OSC = HS
#pragma config WDT = OFF
```

3. Define the bit masks and constants necessary for LED control:
```c
#define LED_RUN LATBbits.LATB15
#define LED_DIRECTION PORTBbits.RB14
#define LED_PATTERN LATB
#define SWITCH_DIRECTION PORTBbits.RB0
#define TIME_INTERVAL 3500
#define LED_PATTERN_DELAY 500
```

4. Setup the required timer for the LED toggle using Timer 1:

```c
void Timer1_Init(void)
{
T1CONbits.TON = 0; // Disable Timer
T1CONbits.TCS = 0; // Select internal instruction cycle clock
T1CONbits.TGATE = 0; // Disable Gated Timer mode
T1CONbits.TCKPS = 0b11; // Select 1:256 Prescaler
TMR1 = 0x00; // Clear timer register
PR1 = TIME_INTERVAL; // Load the period value
IPC0bits.T1IP = 0x01; // Set Timer1 Interrupt Priority Level
IEC0bits.T1IE = 1; // Enable Timer1 interrupt
T1CONbits.TON = 1; // Start Timer
}
```

5. Create the interrupt service routine for Timer 1:
```c
void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void)
{
LED_RUN = !LED_RUN; // Toggle the RUN LED
IFS0bits.T1IF = 0; // Clear the Timer1 interrupt flag
}
```

6. Implement the Knight Rider pattern and pattern direction control:
```c
void Knight_Rider_Pattern(void)
{
uint8_t i;
bool direction = SWITCH_DIRECTION;

while (1)
{
if (direction == 0)
{
for (i = 3; i <= 9; i++)
{
LED_PATTERN = (1 << i);
__delay_ms(LED_PATTERN_DELAY);
}
}
else
{
for (i = 9; i >= 3; i--)
{
LED_PATTERN = (1 << i);
__delay_ms(LED_PATTERN_DELAY);
}
}
}
}
```

7. Implement the main function to initialize the hardware and start the infinite loop:
```c
int main(void)
{
LED_RUN = 0; // Set RUN LED off initially

TRISBbits.TRISB15 = 0; // Set LED_RUN pin as output
TRISBbits.TRISB14 = 1; // Set LED_DIRECTION pin as input
TRISBbits.TRISB0 = 1; // Set SWITCH_DIRECTION as input

while (1)
{
Timer1_Init(); // Initialize Timer 1
Knight_Rider_Pattern(); // Execute Knight Rider pattern
}

return 0;
}
```

That's it! After programming the microcontroller with this code, the Explorer 16 board will run the application as described, with the RUN LED toggling at a 3.5-second interval and the Knight Rider pattern controlled by the switch S3. The process will repeat infinitely.