Hello All, I guess this is my third mail on the same topic. I am trying to control a s= ervo motor using PIC 12F675. I was successful in driving the servo as well = as achieving the speed control for the servo. Thanks for the help from the = members of this list.=A0 Now, my speed control is quite flaky. I tried tweaking my code here and the= re but I have had no success so far. My main objective is that the servo should spin 0 to 90 and back based on t= he data from toggle switch. I achieved this goal. When I turn a potentiomet= er, the speed at which the servo rotates should change. I achieved this too= .. However, the servo is not rotating 90 degrees at all the time.=A0 It rotates 90 ish -120 degrees at high speeds and rotates only 30-45 degree= s on low speeds (or some weird behavior is happening). I want my servo to r= otate 90 degrees but just my speed should vary. Can any one point me to the error in my code?=A0 All this code is inside a while loop. GO_DONE=3D1; while(GO_DONE); V_in=3D(ADRESH<<8)|ADRESL; quotient=3DV_in/200; // I am dividing this because I will have integers bet= ween 1 to 5 if(quotient<=3D1) { quotient=3D1; } if(GPIO&(1<<3)) { while(counter>1000) { counter=3Dcounter-(20*quotient); GPIO|=3D(1<<2); cnt_1=3Dcounter; while(cnt_1>0) { __delay_us(1); cnt_1--; } GPIO&=3D~(1<<2); __delay_ms(18); } cnt=3D1000;//reset of counter for reverse direction } elseif(!(GPIO&(1<<3))) { while(cnt<1500) { cnt=3Dcnt+(20*quotient); GPIO|=3D(1<<2); cnt_2=3Dcnt; while(cnt_2>0) { __delay_us(1); cnt_2--; } GPIO&=3D~(1<<2); __delay_ms(18); } counter=3D1500;//reset of counter for forward direction } } Any help is appreciated Sai } --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .