Take the 2-minute tour ×
LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. It's 100% free, no registration required.

So I need to find objects in an enclosed area, I have access to the standard set of NXT sensors, i.e. ultrasonic/light.

However, the ultrasonic sensors seem to be very unreliable and erratic, in regards to finding objects accurately.

I cannot pre-program the path to the objects, so I'm trying to work out how is the best way to go about locating these objects? The objects are small, and on the floor.

I was thinking a sort of swivel motion at the start, to find any objects using the ultrasonic, and then just moving a small distance at a time, then swivelling again etc. Are there any other better ideas?

Also, there is a wall enclosing the area, would there be a way of programming the NXT to avoid it?

I'll be programming the NXT in NXC. Can't afford LIDAR :(

share|improve this question
In my sensor tests today I found that the ultrasonic sensor just returns 255 if there is no value to return (cable unplugged, or just no answer ready yet). So just filter those out – while ((i = SensorUS(IN_1)) == 255) {} should do the trick. Maybe that helps increasing reliability? –  mirabilos Mar 8 at 22:46
Oh I didn't know that! Thanks for sharing! –  user3089 Mar 9 at 11:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.