#define Relay RB7_bit
long POT,POT2;
unsigned char ar[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
unsigned int compt = 0;
void interrupt()
{
while(INTF)
{
while(POT>=125)
{
point1:
if(POT2>=125)// check the direction from 1 to 2
{
if(compt<9)compt++;
else compt = 9;
Delay_ms(500);
break;
}
else
{
goto point1;
}
}
while(POT2>=125)
{
point2:
if(POT>=125)// check the dirrection from 2 to 1
{
if(compt>0)compt--;
else compt = 0;
Delay_ms(500);
break;
}
else
{
goto point2;
}
}
INTF_bit = 0;// clear flag
break;
}
}
void main(){
TRISA0_bit = 1;//set as input
TRISA1_bit = 1;// set as input
TRISB7_bit = 0;// set as output
TRISB=0x00;
ADCON0 = 0x05;
// interrupt settings...
GIE_bit = 1;// Enable global interrupt
INTE_bit = 1;// Enable external interrupt
INTEDG_bit = 0;// interrupt on falling edge
INTF_bit = 0;
PORTB=ar[compt];
while(1)
{
delay_ms(500);
POT = ADC_Read(0);
POT = POT*255/1023;
POT2= ADC_Read(1);
POT2= POT2*255/1023;
if(compt>0)
Relay = 1;
else
Relay = 0;
PORTB=ar[compt];
}
}