while (1) { // The Slave Reads commands sent from the Master via UART command = EUSART_Read(); if (command == '1') // A '1' signifies a muscle flex and we intend to turn the motor ON { // LED D4 on Curiosity HPC is turned on for servo hold(clockwise) LED_RA6_SetHigh(); //Loop though dutycycle values for continuous motor rotation clockwise for (dutycycle = 20; dutycycle <= 85; dutycycle++) { PWM6_LoadDutyValue(dutycycle); __delay_ms(20); } } else if (command == '0') // A '0' signifies a muscle release and we intend to turn the motor OFF { // LED D4 on Curiosity HPC is turned off for servo release(counter clockwise) LED_RA6_SetLow(); //Loop though dutycycle values for continuous motor rotation counter-clockwise for (dutycycle = 85; dutycycle >= 20; dutycycle--) { PWM6_LoadDutyValue(dutycycle); __delay_ms(20); } } }