| |
You can build this robot with a single
LEGO MINDSTORMS NXT 2.0 set .

|
|
CLICK TO
DOWNLOAD BUILDING INSTRUCTIONS!
Connect
an ultrasonic sensor to input port 4,
and the motor
to output port A. The minimal NXC code is as simple as:
task main ()
{
SetSensorLowspeed(IN_4);
while (true)
{
OnFwd(OUT_A,100);
Wait(1000);
while (SensorUS(IN_4)>20);
OnRev(OUT_A,100);
Wait(2000);
while (SensorUS(IN_4)<40);
}
}
|