Final Project/FinalProject.X/FinalProjectMain.c
// <editor-fold defaultstate="collapsed" desc="debounceRoutine()">
/******************************************************************************
 * debounceRoutine function
 *
 * Debounces a keypress by waiting until a short is greater than 4095, while the
 * state of the pin in question is continuously shifted into the short
 ******************************************************************************/

debounceRoutine function

Debounces a keypress by waiting until a short is greater than 4095, while the
state of the pin in question is continuously shifted into the short
debounceRoutine function Debounces a keypress by waiting until a short is greater than 4095 while the state of the pin in question is continuously shifted into the short
void debounceRoutine() {
    while((debouncedVar<<4) != 65520)
    { 
        buttonPress = PORTD & 0b11110000;
        if(buttonPress >= 1)
        {
            debouncedVar = (debouncedVar<<1) | 0x01;
        }
        else
        {
            debouncedVar = debouncedVar<<1;
        }
        if(debouncedVar<<4 == 0)   
        {
            debouncedVar = 0;
            break;
        }
    }
    debouncedVar = 0;
}
void debounceRoutine ( ) { while ( ( debouncedVar << 4 ) != 65520 ) { buttonPress = PORTD & 0b11110000 ; if ( buttonPress >= 1 ) { debouncedVar = ( debouncedVar << 1 ) | 0x01 ; } else { debouncedVar = debouncedVar << 1 ; } if ( debouncedVar << 4 == 0 ) { debouncedVar = 0 ; break ; } } debouncedVar = 0 ; }
<editor-fold defaultstate="collapsed" desc="debounceRoutine()">
 debounceRoutine function
<editor - fold defaultstate = " collapsed " desc = " debounceRoutine () " > debounceRoutine function