Hello All, I am trying to control a servo motor using a PIC12F675 with a toggle switch= .. When the switch is one state, the servo goes forward and the other state,= the motor goes reverse.=A0 Here is something that I tried: _CONFIG(WDTDIS&PWRTEN&MCLRDIS&BOREN&UNPROTECT&INTCLK); #define_XTAL_FREQ4000000 voidmain(void){ TRISIO=3D(1<<3)|(1<<4); while(1){ if(GPIO3) { GPIO=3D(1<<2); __delay_us(900); GPIO&=3D~(1<<2); __delay_us(100); __delay_ms(19); //here the total time pulse is 20 ms including ON time } if(GPIO4) { GPIO=3D(1<<2); __delay_us(2100); GPIO&=3D~(1<<2); __delay_us(900); __delay_ms(17); } } } My main need is that the servo should spin in opposite directions whenever = the switch changes state. The motor changes position only once and nothing = happens after that.=A0 I am not able to find out what is wrong here. I also tried making the motor= move in opposite directions without any switch control. The servo does not= spin as it should. It stays at the same position and makes some jerky move= ments. I am looking forward to your suggestion regarding the same. Sai --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .