/** Header Files ***************************************************/ #include #include /** Configuration Bits *********************************************/ #pragma config OSC = INTIO67 #pragma config WDT = OFF #pragma config LVP = OFF #pragma config BOREN = OFF #pragma config XINST = OFF /** Define Constants Here ******************************************/ #define PRESSED 0 /******************************************************************* * Function: void main(void) ********************************************************************/ #pragma code void main(void) { // Set the clock to 250 kHz OSCCONbits.IRCF2 = 0; OSCCONbits.IRCF1 = 1; OSCCONbits.IRCF0 = 0; // Pin IO Setup ADCON1 = 0x0F; TRISB = 0xFF; // All of PORTB input TRISC = 0x00; // All of PORTC output PORTC = 0x00; while (1) { if (PORTBbits.RB3 == PRESSED) { PORTCbits.RC7 = 1; Delay1KTCYx(62); Delay100TCYx(5); PORTCbits.RC7 = 0; while(PORTBbits.RB3 == PRESSED); } // Or // You could use the recentButtonState PRESSED UNPRESSED approach // That approach would be very similar to your Lab 3 problems. } }