int select[9] = {0x00, 0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F};
int cnt = 1;
int flag = 0;
void Interrupt() {
if (INTF_bit){
INTE_bit = 0;
if (Button(&PORTA, 0, 1, 1)) // Button pressed on PortA.0
cnt ++;
if (cnt >= 9){
cnt = 1;}
INTF_bit = 0; // CLear INTF flag
flag = 1;
}
if (Button(&PORTA, 1, 1, 1)) { // Button pressed on PortA.1
cnt --;
if (cnt < 1){
cnt = 8;}
INTF_bit = 0; // Clear INTF flag
flag = 1;
}
}
void main() {
ANSELA = 0;
ANSELB = 0;
TRISA = 0xff; //PORTA.0, PORTA.1 is input
TRISB = 0; //PORTB is output
TRISC = 0;
PORTB = 0xFF;
GIE_bit = 1;
PEIE_bit = 0;
INTE_bit = 1;
INTEDG_bit = 1;
do{
if(flag==1){ // Interrupt
LATB = select[cnt];
flag = 0; //Reset flag
INTE_bit = 1; //Re-enable External interrupt
}
}while(1);
}