thank you all for your replies, i understand what you all are saying about the delay and such, but the real problem here is controlling the motor speed WITH the sensor values coding. if anyone can assist me on this please let me know. i'll make the changes you guys have pointed out