You need to remember the state of each input, and only output to the UART if it changes. Something like this, just for one input so you get the idea : // NB - put these lines outside your loop uint8_t uLastRA6State = 0; // last known state of RA6 uint8_t uLastRA7State = 0; // last known state of RA7 // ... etc. // use one variable for each input while (1) { // ... // NB - put this code inside your loop if (PORTAbits.RA6 != uLastRA6State) { // save current state uLastRA6State = uLastRA6State ? 0 : 1; // output change if (uLastRA6State) putsUART2("Input: 1 ON\n"); else putsUART2("Input: 1 OFF\n"); } // ... do the same for other inputs, e.g. if (PORTAbits.RA7 != uLastRA7State) { // ... similar to above, for RA7 } }