I am working on a project to have my lego NXT navigate through block obstacles using the NXT sonar. I have modified my NXT, I have a motor mounted to left side of my NXT and the sonar is mounted on the motor. Now the problem is how to control my motor so that my sonar is always in the forward position relative to my NXT.
My NXT moves the motor for my sensor to detect the block obstacles and moves towards it, when my NXT is at a certain distance away from the block it avoids the obstacle but for some reason I cannot get my motor to return to the center or original position I have looked through the robotC IDE on how to control the motor but I donít fully understand how those functions work.
My point is any time my motor moves to detect an obstacle I want to return it to the original position. Also I want the motor to rotate from (-180 to 180) degrees. Please if you know an algorithm that will help me accomplish this task I will be most grateful. Thank You!