#define F_CPU 16000000UL #include #include #include #include #include #include "mfes.h" #define Pot1 0 int main(void) { char choice ; short potentiometer; char pot_str[10]; int i; int MFES_RdButton(int button); short MFES_RdPot(void); // Initialise expansion board MFES_Init(); // Initialise serial port to 9600 8,N,1 UART_Init(); while(1) { // Store potentiometer value potentiometer = MFES_RdPot(); // Chech if command received. Command must end in '\r' if(USART_ReadLine()) { // Command received // Store first character of command choice = CmdLine[0]; // Store 7 segment number for relevant choice // ************ place code here ************ // Provide response to command switch (choice) { case 'A': case 'B': case 'C': case 'D': case 'E': USART_SendChar(choice); itoa(potentiometer, pot_str, 10); USART_SendString(pot_str); USART_SendString("\r\n"); break; default: USART_SendString("Error: "); USART_SendString(CmdLine); USART_SendString("\r\n"); break; } } // Parse the first character switch(choice) { case 'A': // Turn LED on and off MFES_LedOn(0); _delay_ms(100); MFES_LedOff(0); _delay_ms(100); break; case 'B': if (MFES_RdButton(1)) //checks if button is pressed MFES_LedOn(0); //Turn on D1 else MFES_LedOff(0); //Turn D1 off if (MFES_RdButton(2)) //checks if button is pressed MFES_LedOn(1); //Turn on D1 else MFES_LedOff(1); //Turn D1 off if (MFES_RdButton(3)) //checks if button is pressed MFES_LedOn(2); //Turn on D1 else MFES_LedOff(2); //Turn D1 off break; case 'C': MFES_Wr7SegInt(potentiometer); break; case 'D': break; case 'E': // ************ place code here ************ break; default: // ************ place code here ************ break; } } }