Hi, Please have a look at the below code. The chip is 16f84a. The osilator is selected as xt and the wdt is disabled. There is a button on RB0 to trigger the interrupt and there is a motor driver on pins RB1 and RB2. What I want to do is to count the button presses and change the direction of the motor when It reaches to the specified values (max and min) I will be very happy if someone can help me in the project. The hi-tech C code (lite version): #include #define PIC_CLK 4000000 #include #define CP_off|=0x3FFF//copy protect off #define OUTPUT 0; #define INPUT 1; unsigned char max; unsigned char min; unsigned char pos=9; unsigned char dir=1; main(){ // init TRISB=49; PORTB=0; max=20; min=10; INTE=1; GIE=1; for(;;){ if (pos>max) { dir=0; RB1=0;//motor left RB2=1;//motor left } if (pos