Download Program:el-toro-nxt-robot.rbt
This Page as PDF:el-toro-nxt-robot.pdf
Video:Youtube Video

El Toro (The Bull) NXT Robot

Stefan Bracher

El Toro is Spanish for "the bull". Like a real bull, this robot attacks whatever gets too close to him. When left alone, El Toro turns slowly around, looking if there is someone daring to approach it. As soon as El Toro spots something within its reach, it starts moving straight forward.

El Toro (the Bull) NXT-Robot


The NXT ultrasound sensor

The NXT ultrasound-sensor measures the time a sound wave needs to travel from the robot to an object (where it is reflected) and back. As sound travels at an almost constant speed of 1200 km/h, the robot can calculate the distance to the object (distance=time*speed of sound/2). Not only our robot, but also bats and wales use this principle to "see" in the dark.

In G-Code, the sensor block gives us directly the distance to the object, either in centimeters or inches.

NXT-G Code

NXT G-Code

The program consists of a loop that runs forever. Within that loop, a switch command is used. It compares the distance measured by the ultrasound sensor to a given threshold value.

As seen on the left, 80cm has been chosen to be our threshold. If the value read by the sensor is smaller, the upper part of the switch command is executed, if the value is bigger, the lower part of the switch command is executed.

In the first case (distance < 80 cm), both motors are given full power in the same direction, thus the robot will run straight forward.

In the second case (distance > 80 cm), motor C is running backwards while motor B is running forwards. The robots thus turns around itself.


-When turning around itself, use a relatively slow speed.
-Make sure no parts or wires are obstructing the view of the ultrasound sensor.